changeset 1623:897cfcae1975

EditLog.news gives new items since some timestamp
author Thomas Waldmann <tw AT waldmann-edv DOT de>
date Wed, 18 Oct 2006 03:22:43 +0200
parents 7d199191cb1f
children 0b0b94e1680f
files MoinMoin/Page.py MoinMoin/logfile/editlog.py
diffstat 2 files changed, 20 insertions(+), 15 deletions(-) [+]
line wrap: on
line diff
--- a/MoinMoin/Page.py	Wed Oct 18 02:16:11 2006 +0200
+++ b/MoinMoin/Page.py	Wed Oct 18 03:22:43 2006 +0200
@@ -25,8 +25,6 @@
         We only cache this to RAM in request.cfg (this is the only kind of
         server object we have), because it might be too big for pickling it
         in and out.
-
-        Todo: add acl / and other item meta data like mimetype
     """
     def __init__(self):
         self.cache = {}
@@ -70,19 +68,13 @@
         """
         from MoinMoin.logfile import editlog
         elog = editlog.EditLog(request)
-        timestamp = elog.date()
-        if self.timestamp is None:
-            self.timestamp = timestamp
-        elif self.timestamp != timestamp:
-            self.timestamp = timestamp
-            for line in elog.reverse():
-                if line.ed_time_usecs < self.timestamp: # XXX t1 <= t2 ???
-                    break
-                logging.debug("cache: removing %r" % line.pagename)
-                try:
-                    del self.cache[line.pagename]
-                except:
-                    pass
+        self.timestamp, items = elog.news(self.timestamp)
+        for item in items:
+            logging.debug("cache: removing %r" % item)
+            try:
+                del self.cache[item]
+            except:
+                pass
 
 
 class Page:
--- a/MoinMoin/logfile/editlog.py	Wed Oct 18 02:16:11 2006 +0200
+++ b/MoinMoin/logfile/editlog.py	Wed Oct 18 03:22:43 2006 +0200
@@ -208,3 +208,16 @@
         self.filter = eval("lambda x: " + expr)
 
 
+    def news(self, oldtimestamp):
+        """ What has changed in the edit-log since <timestamp>?
+            Returns edit-log timestamp and list of changed item names.
+        """
+        newtimestamp = self.date()
+        items = []
+        if oldtimestamp is not None and oldtimestamp != newtimestamp:
+            for line in self.reverse():
+                if line.ed_time_usecs < oldtimestamp: # XXX t1 <= t2 ???
+                    break
+                items.append(line.pagename)
+        return newtimestamp, items
+