# HG changeset patch # User k0s # Date 1264564851 18000 # Node ID 689b9d928dc8fca587b79be224b3bb557bdaa1e5 # Parent aebfbb10aefba74d435f331136734421f026140d add date, reflect api change of lxmlmiddleware diff -r aebfbb10aefb -r 689b9d928dc8 commentator/middleware.py --- a/commentator/middleware.py Sun Jan 24 17:40:54 2010 -0500 +++ b/commentator/middleware.py Tue Jan 26 23:00:51 2010 -0500 @@ -7,7 +7,8 @@ import re from handlers import PostComment -from model import CouchComments, PickleComments +#from model import CouchComments +from model import PickleComments from genshi.template import TemplateLoader from lxml import etree from lxmlmiddleware import LXMLMiddleware @@ -24,6 +25,7 @@ ### class level variables defaults = { 'auto_reload': 'False', 'database': 'commentator', + 'date_format': '%H:%M %m/%d/%Y', 'template_dirs': '', 'pattern': '.*', 'path': 'html', @@ -86,8 +88,8 @@ res = handler() return res(environ, start_response) - def manipulate(self, environ, tree): - url_match = re.match(self.url_pattern, environ['commentator.path_info']) + def manipulate(self, request, response, tree): + url_match = re.match(self.url_pattern, request.environ['commentator.path_info']) if not url_match: return tree @@ -110,6 +112,8 @@ data = {} data['comments'] = self.model.comments(uri) data['action'] = '%s/%s' % (uri, self.url) + data['date_format'] = self.date_format + data['request'] = request # render template template = self.loader.load(self.template) diff -r aebfbb10aefb -r 689b9d928dc8 commentator/model.py --- a/commentator/model.py Sun Jan 24 17:40:54 2010 -0500 +++ b/commentator/model.py Tue Jan 26 23:00:51 2010 -0500 @@ -13,6 +13,7 @@ f.close() def comment(self, uri, **kw): + kw['date'] = datetime.now() f = file(self.database) comments = pickle.load(f) f.close() diff -r aebfbb10aefb -r 689b9d928dc8 commentator/templates/comment.html --- a/commentator/templates/comment.html Sun Jan 24 17:40:54 2010 -0500 +++ b/commentator/templates/comment.html Tue Jan 26 23:00:51 2010 -0500 @@ -9,13 +9,20 @@
${comment['author']} - + ${comment['date'].strftime(date_format)}

${comment['body']}

+
+ + + +
+
Name:
+
URL:
diff -r aebfbb10aefb -r 689b9d928dc8 setup.py --- a/setup.py Sun Jan 24 17:40:54 2010 -0500 +++ b/setup.py Tue Jan 26 23:00:51 2010 -0500 @@ -5,7 +5,7 @@ except IOError: description = '' -version = "0.1" +version = "0.2" setup(name='commentator', version=version,