我想在调用static_url()时关闭?v =版本信息。
我有以下staticFileHandler类,我尝试覆盖make_static_url()类方法:
class BaseHandlerStatic(tornado.web.StaticFileHandler):
@classmethod
def make_static_url(cls, settings, path, include_version=False):
super().make_static_url(settings, path, include_version)
不幸的是,这样做会导致我的程序因500错误而崩溃:
"/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/site-packages/tornado-4.5.dev1-py3.5-macosx-10.6-intel.egg/tornado/web.py", line 1342, in static_url
return base + get_url(self.settings, path, **kwargs)
TypeError: Can't convert 'NoneType' object to str implicitly
[E 170213 16:23:32 web:1977] 500 GET / (127.0.0.1) 14.66ms
有人可以告诉我我做错了什么以及如何将include_version设置为False?
由于
答案 0 :(得分:2)
您需要return
声明:
class BaseHandlerStatic(tornado.web.StaticFileHandler):
@classmethod
def make_static_url(cls, settings, path, include_version=False):
return super().make_static_url(settings, path, include_version)
否则你的make_static_url会隐式返回None,而base + get_url(...)
表达式会尝试将base
与None
连接起来引发异常。