--- a/lib/page.py Sat Feb 07 03:35:37 2009 +0200
+++ b/lib/page.py Sat Feb 07 04:37:28 2009 +0200
@@ -5,6 +5,7 @@
# for filesystem ops
import os, os.path
+import time
# for ResponseError
import http
@@ -30,7 +31,7 @@
This object represents the information about our attempt to render some specific page
"""
- def __init__ (self, url, path, basename, url_tail) :
+ def __init__ (self, url, path, basename, url_tail, charset='utf8') :
"""
Initialize the page at the given location
@@ -38,6 +39,7 @@
@param path the filesystem path to this page's file
@param basename the filesystem name of this page's file, without the file extension
@param url_trail trailing URL for this page
+ @param charset file charset
"""
# store
@@ -45,6 +47,7 @@
self.path = path
self.basename = basename
self.url_tail = url_tail
+ self.charset = charset
# unbound
self.request = None
@@ -93,6 +96,17 @@
"""
abstract
+
+ @property
+ def modified (self) :
+ """
+ Returns the page modification timestamp
+ """
+
+ # stat
+ timestamp = os.stat(self.path).st_mtime
+
+ return time.strftime("%Y/%m/%d %H:%M %Z", time.gmtime(timestamp))
class HTMLPage (Page) :
"""
@@ -105,7 +119,7 @@
Opens the .html file, reads and returns contents
"""
- return open(self.path, 'rb').read()
+ return open(self.path, 'rb').read().decode(self.charset)
class TemplatePage (Page) :
"""