changeset 3:d0d8524d9495

finish basic API...still doesnt expire results correctly
author k0s <k0scist@gmail.com>
date Fri, 26 Feb 2010 11:06:48 -0500
parents 689b9d928dc8
children f02a3672254e
files commentator/middleware.py commentator/model.py
diffstat 2 files changed, 13 insertions(+), 4 deletions(-) [+]
line wrap: on
line diff
--- 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
--- 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()