Skip to content

Commit

Permalink
Rename StaticFileHandler.get_entity_tag to compute_etag_for_path
Browse files Browse the repository at this point in the history
  • Loading branch information
alekstorm committed Jun 26, 2012
1 parent 8b332d7 commit 46f520a
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions tornado/web.py
Expand Up @@ -1555,7 +1555,7 @@ def get(self, path, include_body=True):
stat_result = os.stat(abspath)[stat.ST_MTIME] stat_result = os.stat(abspath)[stat.ST_MTIME]
modified = datetime.datetime.fromtimestamp(stat_result) modified = datetime.datetime.fromtimestamp(stat_result)
self.set_header("Last-Modified", modified) self.set_header("Last-Modified", modified)
self.set_header("Etag", '"%s"' % self.get_entity_tag(abspath)) self.set_header("Etag", '"%s"' % self.compute_etag_for_path(abspath))


mime_type, encoding = mimetypes.guess_type(abspath) mime_type, encoding = mimetypes.guess_type(abspath)
if mime_type: if mime_type:
Expand Down Expand Up @@ -1628,19 +1628,19 @@ def get_version(cls, settings, path):
This method may be overridden in subclasses (but note that it This method may be overridden in subclasses (but note that it
is a class method rather than a static method). The default is a class method rather than a static method). The default
implementation calls `get_entity_tag`. implementation calls `compute_etag_for_path`.
``settings`` is the `Application.settings` dictionary and ``path`` ``settings`` is the `Application.settings` dictionary and ``path``
is the relative location of the requested asset on the filesystem. is the relative location of the requested asset on the filesystem.
The returned value should be a string, or ``None`` if no version The returned value should be a string, or ``None`` if no version
could be determined. could be determined.
""" """
entity_tag = cls.get_entity_tag(os.path.join(settings["static_path"], entity_tag = cls.compute_etag_for_path(os.path.join(settings["static_path"],
path)) path))
return entity_tag[:5] if entity_tag else None return entity_tag[:5] if entity_tag else None


@classmethod @classmethod
def get_entity_tag(cls, abspath): def compute_etag_for_path(cls, abspath):
"""Generate the entity tag to be used in static URLs and the Etag """Generate the entity tag to be used in static URLs and the Etag
header. header.
Expand Down

0 comments on commit 46f520a

Please sign in to comment.