changeset 3610:39456a5dc4e8

fix failure of detection of on-disk cache updates (this fixes unreliable dicts/groups tests), remove unused Page attribute
author Thomas Waldmann <tw AT waldmann-edv DOT de>
date Sat, 17 May 2008 21:23:09 +0200
parents 9653e7a9bcc4
children 0b220c040be4
files MoinMoin/Page.py MoinMoin/caching.py MoinMoin/wikidicts.py
diffstat 3 files changed, 15 insertions(+), 6 deletions(-) [+]
line wrap: on
line diff
--- a/MoinMoin/Page.py	Sat May 17 19:54:30 2008 +0200
+++ b/MoinMoin/Page.py	Sat May 17 21:23:09 2008 +0200
@@ -1356,7 +1356,6 @@
                        self.page_name.encode(config.charset), 'exec')
         cache = caching.CacheEntry(request, self, self.getFormatterName(), scope='item')
         cache.update(marshal.dumps(code))
-        self.cache_mtime = cache.mtime()
         return code
 
     def _specialPageText(self, request, special_type):
--- a/MoinMoin/caching.py	Sat May 17 19:54:30 2008 +0200
+++ b/MoinMoin/caching.py	Sat May 17 21:23:09 2008 +0200
@@ -81,11 +81,20 @@
         return os.path.exists(self._filename())
 
     def mtime(self):
+        # DEPRECATED for checking a changed on-disk cache, please use
+        # self.uid() for this, see below
         try:
             return os.path.getmtime(self._filename())
         except (IOError, OSError):
             return 0
 
+    def uid(self):
+        """ Return a value that likely changes when the on-disk cache was updated.
+
+            See docstring of MoinMoin.util.filesys.fuid for details.
+        """
+        return filesys.fuid(self._filename())
+
     def needsUpdate(self, filename, attachdir=None):
         # following code is not necessary. will trigger exception and give same result
         #if not self.exists():
--- a/MoinMoin/wikidicts.py	Sat May 17 19:54:30 2008 +0200
+++ b/MoinMoin/wikidicts.py	Sat May 17 21:23:09 2008 +0200
@@ -207,7 +207,7 @@
         self.dictdict = {}
         self.groupdict = {} # unexpanded groups
         self.picklever = DICTS_PICKLE_VERSION
-        self.disk_cache_mtime = 0
+        self.disk_cache_id = None
 
     def has_member(self, groupname, member):
         """ check if we have <member> as a member of group <groupname> """
@@ -289,10 +289,11 @@
         arena = 'wikidicts'
         key = 'dicts_groups'
         cache = caching.CacheEntry(request, arena, key, scope='wiki', use_pickle=True)
-        current_disk_cache_mtime = cache.mtime()
+        current_disk_cache_id = cache.uid()
         try:
             self.__dict__.update(self.cfg.cache.DICTS_DATA)
-            if current_disk_cache_mtime > self.disk_cache_mtime:
+            if (current_disk_cache_id is None or
+                current_disk_cache_id != self.disk_cache_id):
                 self.reset()
                 raise AttributeError # not fresh, force load from disk
             else:
@@ -301,7 +302,7 @@
             try:
                 data = cache.content()
                 self.__dict__.update(data)
-                self.disk_cache_mtime = current_disk_cache_mtime
+                self.disk_cache_id = current_disk_cache_id
 
                 # invalidate the cache if the pickle version changed
                 if self.picklever != DICTS_PICKLE_VERSION:
@@ -316,7 +317,7 @@
             return
 
         data = {
-            "disk_cache_mtime": self.disk_cache_mtime,
+            "disk_cache_id": self.disk_cache_id,
             "dictdict": self.dictdict,
             "groupdict": self.groupdict,
             "picklever": self.picklever