def validate_absolute_path(self, root, absolute_path):
"""
An override of
:meth:`tornado.web.StaticFileHandler.validate_absolute_path`;
Validate and returns the given *absolute_path* using `pkg_resources`
if ``self.use_pkg`` is set otherwise performs a normal filesystem
validation.
"""
# We have to generate the real absolute path in this method since the
# Tornado devs--for whatever reason--decided that get_absolute_path()
# must be a classmethod (we need access to self.use_pkg).
if self.use_pkg:
if not resource_exists(self.use_pkg, absolute_path):
raise HTTPError(404)
return resource_filename(self.use_pkg, absolute_path)
return super(
StaticHandler, self).validate_absolute_path(root, absolute_path)
评论列表
文章目录