1.1 --- a/WebStack/Resources/Static.py Sat Nov 15 02:33:55 2008 +0100
1.2 +++ b/WebStack/Resources/Static.py Mon Nov 17 19:52:59 2008 +0100
1.3 @@ -22,7 +22,17 @@
1.4
1.5 from WebStack.Generic import ContentType, EndOfResponse
1.6 import os
1.7 -import email.utils
1.8 +try:
1.9 + from email.utils import formatdate
1.10 +except ImportError:
1.11 + from email.Utils import formatdate as _formatdate
1.12 + def formatdate(timeval=None, localtime=False, usegmt=False):
1.13 + s = _formatdate(timeval, localtime)
1.14 + l = s.split(" ") # get components
1.15 + if usegmt:
1.16 + del l[-1] # remove time-zone offset
1.17 + l.append("GMT") # add mandatory name
1.18 + return " ".join(l)
1.19
1.20 class DirectoryResource:
1.21
1.22 @@ -119,7 +129,7 @@
1.23 # Write the file to the client.
1.24
1.25 pathname = os.path.join(self.directory, filename)
1.26 - mtime = email.utils.formatdate(os.path.getmtime(pathname), usegmt=1)
1.27 + mtime = formatdate(os.path.getmtime(pathname), usegmt=1)
1.28 trans.set_header_value("Last-Modified", mtime)
1.29
1.30 f = open(pathname, "rb")
1.31 @@ -148,7 +158,7 @@
1.32 self.content_type = content_type
1.33
1.34 def respond(self, trans):
1.35 - mtime = email.utils.formatdate(os.path.getmtime(self.filename), usegmt=1)
1.36 + mtime = formatdate(os.path.getmtime(self.filename), usegmt=1)
1.37
1.38 trans.set_content_type(self.content_type)
1.39 trans.set_header_value("Last-Modified", mtime)