Reputation: 1452
I want to turn off the ?v= version information when static_url() is called.
I have the following staticFileHandler class where I try and override the make_static_url() classmethod:
class BaseHandlerStatic(tornado.web.StaticFileHandler):
@classmethod
def make_static_url(cls, settings, path, include_version=False):
super().make_static_url(settings, path, include_version)
unfortunately doing this causes my program to crash with at 500 errors:
"/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
Can someone please tell me what i'm doing wrong and how I can set include_version to False?
Thanks
Upvotes: 1
Views: 90
Reputation: 24007
You need a return
statement:
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)
Otherwise your make_static_url returns None implicitly, and the base + get_url(...)
expression throws an exception trying to catenate base
with None
.
Upvotes: 2