# HG changeset patch # User k0s # Date 1267200408 18000 # Node ID d0d8524d949580f8f7896456abffbdeef34348ea # Parent 689b9d928dc8fca587b79be224b3bb557bdaa1e5 finish basic API...still doesnt expire results correctly diff -r 689b9d928dc8 -r d0d8524d9495 commentator/middleware.py --- a/commentator/middleware.py Tue Jan 26 23:00:51 2010 -0500 +++ b/commentator/middleware.py Fri Feb 26 11:06:48 2010 -0500 @@ -97,6 +97,7 @@ groups_dict = dict([(str(index+1), value) for index, value in enumerate(url_match.groups())]) + last_modified = None for element in tree.findall(self.xpath_pattern): # get url @@ -105,12 +106,11 @@ str_dict[key] = element.get(key) uri = self.mapping.substitute(str_dict) - # get comments - # TODO - # genshi data data = {} data['comments'] = self.model.comments(uri) + if data['comments']: + last_modified = data['comments'][-1]['date'] data['action'] = '%s/%s' % (uri, self.url) data['date_format'] = self.date_format data['request'] = request @@ -121,4 +121,6 @@ comments = etree.fromstring(comments) element.append(comments) + if last_modified: + import pdb; pdb.set_trace() return tree diff -r 689b9d928dc8 -r d0d8524d9495 commentator/model.py --- a/commentator/model.py Tue Jan 26 23:00:51 2010 -0500 +++ b/commentator/model.py Fri Feb 26 11:06:48 2010 -0500 @@ -2,6 +2,7 @@ import pickle from datetime import datetime +from webob import _UTC class PickleComments(object): # TODO: locking @@ -13,7 +14,13 @@ f.close() def comment(self, uri, **kw): - kw['date'] = datetime.now() + now = datetime.utcnow() + now.replace(tzinfo=_UTC()) + + # tzinfo crap +# now = datetime(*list(now.utctimetuple()[:-1]) + [_UTC()]) + + kw['date'] = now f = file(self.database) comments = pickle.load(f) f.close()