这是一个创建于 4449 天前的主题,其中的信息可能已经有所发展或是发生改变。
我想在跳转后的页面上显示错误信息,我记得以前的pylons版本是可以保留数据的,不知道是不是没有配置正确。
举个例子,代码是这样的
from pylons import tmpl_context as c
from pylons.controllers.util import redirect
class TestController(BaseController):
def test1(self):
c.message="error message"
redirect("/test/test2")
def test2(self):
return c.message
访问test1,跳转到test2页面就出错了,提示'ContextObj' object has no attribute 'message'。
3 条回复 • 1970-01-01 08:00:00 +08:00
|
|
1
Livid 2012-08-15 04:52:58 +08:00 1
跳转前设定 message,然后在跳转后显示,这样的 message 通常应该是存在 session storage 里的。
|
|
|
2
Js 2012-08-15 09:29:52 +08:00 1
用flash或者session
tmpl_context只是当前请求拿来放模板变量的容器
|
|
|
3
dodogod 2012-08-15 17:02:13 +08:00
flash是用session实现的吧? 谢谢楼上 之前应该是用session,我记错了。
|