0

StaticFileHandlerファイルリクエストを処理できるように拡張しようとしていself.render(filename, **kwargs)ますが、ファイルを呼び出して実際にクライアントに提供します。(はい、その時点で、それ自体が静的ファイルではなくなっていることに気付きました)。

実行しようとしているコードは次のとおりです。

class MustacheFileHandler(tornado.web.StaticFileHandler):
    def get(self, filename):
        self.render(_STATIC_ROOT_ + '/' + path.split('/')[len(path.split('/'))-2], userLoginStatus='you are logged out!')

# ...
class Application(tornado.web.Application):
    def __init__(self, **overrides):
         handlers = [(r'/(.*)', MustacheFileHandler, {'path' : _STATIC_ROOT_})]
# ...

..._STATIC_ROOT_起動時にロードされるサーバーの構成ファイルに含まれる変数はどこですか。

私が抱えている問題はGET、サーバー上に存在することがわかっているファイルに対して実行しようとすると、次のエラーが発生することです。

Traceback (most recent call last):
  File "/usr/local/lib/python2.7/dist-packages/tornado/web.py", line 1332, in _execute
    result = method(*self.path_args, **self.path_kwargs)
  File "myfile.py", line 173, in get
    self.render(_STATIC_ROOT_ + '/' + path.split('/')[len(path.split('/'))-2], userLoginStatus='you are logged out!')
  File "/usr/local/lib/python2.7/dist-packages/tornado/web.py", line 747, in render
    self.finish(html)
  File "/usr/local/lib/python2.7/dist-packages/tornado/web.py", line 877, in finish
    self.set_etag_header()
  File "/usr/local/lib/python2.7/dist-packages/tornado/web.py", line 1257, in set_etag_header
    etag = self.compute_etag()
  File "/usr/local/lib/python2.7/dist-packages/tornado/web.py", line 2185, in compute_etag
    version_hash = self._get_cached_version(self.absolute_path)
AttributeError: 'MustacheFileHandler' object has no attribute 'absolute_path'

このエラーの原因や対処方法がわかりません。

4

1 に答える 1