tornado中关闭autoescape

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 = tornado.web.Application([
    (r"/",MainHandler),
    (r"/login",loginHandler),
],**settings)    #这儿传入


猜你喜欢

转载自onlyugly.iteye.com/blog/1571559