Athena LivePage的页面刷新异常和解决方法
2009-05-07 14:05
357 查看
Athena的LivePage对象很好用,但是在刷新的时候,会有一个异常:
exceptions.AssertionError: Cannot render a LivePage more than once
官方说法是:
LivePage instances maintain server-side state that corresponds to the connection to the browser. Because of this, each LivePage instance can only be used to serve a single client. When you serve LivePages?, make sure that you create a new instance for each render pass.
LivePage对象维护着服务端的状态,这个状态对应着从浏览器过来的连接。因此,每个LivePage对象只能用来为一个客户端服务。当你使用LivePage,一定要保证在render的时候,传回一个新对象。
每次使用LivePage,总要创建新实例。
------------------------------------July 19 更新----------------------------------
我们有一个Index的页面,是LivePage, 想让用户访问的第一个页面就是这个。
那在site对象建立的时候,我们就需要一个实例:
site = appserver.NevowSite(Index())
这样是不能刷新的,会有AssertionError错误。
那就这样,我们写一个RootPage, 在这个RootPage中,不论用户访问什么,总返回一个新的Index:
class RootPage(????):
'''
always return a new Index
'''
def child_(self, ctx):
return Index()
然后:
site = appserver.NevowSite(RootPage())
这样不就行了嘛。
我打"?"的地方是有问题的。
如果RootPage从rend.Page继承,Athena所有的js框架和自己的js文件(模板中,render "liveglue"生成)都不能被正确的加载。
要想这些js被加载,RootPage必须继承LivePage, 这样,就陷入死循环了。
具体解决的办法是:
class RootPage(Index):
'''
always return a new Index
'''
def child_(self, ctx):
return Index()
这样就保证不会出现刷新问题。
exceptions.AssertionError: Cannot render a LivePage more than once
官方说法是:
LivePage instances maintain server-side state that corresponds to the connection to the browser. Because of this, each LivePage instance can only be used to serve a single client. When you serve LivePages?, make sure that you create a new instance for each render pass.
LivePage对象维护着服务端的状态,这个状态对应着从浏览器过来的连接。因此,每个LivePage对象只能用来为一个客户端服务。当你使用LivePage,一定要保证在render的时候,传回一个新对象。
每次使用LivePage,总要创建新实例。
------------------------------------July 19 更新----------------------------------
我们有一个Index的页面,是LivePage, 想让用户访问的第一个页面就是这个。
那在site对象建立的时候,我们就需要一个实例:
site = appserver.NevowSite(Index())
这样是不能刷新的,会有AssertionError错误。
那就这样,我们写一个RootPage, 在这个RootPage中,不论用户访问什么,总返回一个新的Index:
class RootPage(????):
'''
always return a new Index
'''
def child_(self, ctx):
return Index()
然后:
site = appserver.NevowSite(RootPage())
这样不就行了嘛。
我打"?"的地方是有问题的。
如果RootPage从rend.Page继承,Athena所有的js框架和自己的js文件(模板中,render "liveglue"生成)都不能被正确的加载。
要想这些js被加载,RootPage必须继承LivePage, 这样,就陷入死循环了。
具体解决的办法是:
class RootPage(Index):
'''
always return a new Index
'''
def child_(self, ctx):
return Index()
这样就保证不会出现刷新问题。
相关文章推荐
- JavaScript页面刷新与弹出窗口问题解决方法
- 解决刷新页面造成数据重复提交的方法(转载)
- JavaScript页面刷新与弹出窗口问题的解决方法
- 解决struts2 acton redirect 后不能刷新的问题 另:实现页面框架局部刷新的方法
- SubmitOncePage:解决刷新页面造成的数据重复提交问题
- ios开发之webView.scalesPageToFit = YES后 加载页面遇见表格显示很小的解决方法
- 关于在FireFox 3.0 中showModalDialog的页面刷新window.dialogArguments引用丢失的解决方法
- JavaScript页面刷新与弹出窗口问题解决方法
- linux环境配置nginx导致页面不刷新的解决方法
- javascript refresh page 几种页面刷新的方法
- AngularJS进阶(二十八)解决AngualrJS页面刷新导致异常显示问题
- JavaScript页面刷新与弹出窗口问题解决方法
- SubmitOncePage:解决刷新页面造成的数据重复提交问题
- SubmitOncePage:解决刷新页面造成的数据重复提交问题
- JavaScript页面刷新与弹出窗口问题的解决方法
- 【操作系统】chrome插件无法安装解决方法或者提示“将该项添加到 Chrome 浏览器时出错。请刷新此页面,然后重试。”的解决办法
- struts2 笔记03 异常支持、防止页面刷新和后退、方法验证
- JavaScript页面刷新与弹出窗口问题解决方法
- 刷新页面出现重试和取消解决方法
- 页面刷新后 Ueditor 无法实例化的解决方法