现在的位置: 首页 > 综合 > 正文

tornado中关闭autoescape

2012年07月17日 ⁄ 综合 ⁄ 共 541字 ⁄ 字号 评论关闭

2.1版本中的tornado,使用了自动的escape功能,这个在使用xsrf_form_html函数的时候,会将这些字符转义出来,导致浏览器出现本应该隐藏内容的显示问题。

 

在tornado.web中,有关于autoescape方法的获取,发现在settings中修改即可。

于是在settings中添加 "autoescape":None

 

问题得以解决。

 

settings 配置如下:

settings = {
"debug" : True, # will auto reload
"cookie_secret": "jNU893FLQp3vauUciqEQZbTtBSApVSp4IvNZj19V/Vo=",
"login_url" : "/login",
"xsrf_cookies" : True,
"static_url_prefix" : "/static/",
"template_path" : os.path.join( workpath, "template"),
"static_path" : os.path.join( workpath, "static"),
'autoescape' : None
}

 

在Application.__init__(self, urlpatterns, **settings)初始化的时候传递进去即可。

抱歉!评论已关闭.