diff MoinMoin/caching.py @ 681:2d5883e4b82c

scope == {'item', 'wiki', 'farm'} for caching
author Thomas Waldmann <tw AT waldmann-edv DOT de>
date Sun, 21 May 2006 18:01:23 +0200
parents d6556513c4d3
children a2beb43407ea
line wrap: on
line diff
--- a/MoinMoin/caching.py	Sun May 21 16:54:45 2006 +0200
+++ b/MoinMoin/caching.py	Sun May 21 18:01:23 2006 +0200
@@ -21,6 +21,10 @@
             @param arena: either a string or a page object, when we want to use
                           page local cache area
             @param key: under which key we access the cache content
+            @param scope: the scope where we are caching:
+                          'item' - an item local cache
+                          'wiki' - a wiki local cache
+                          'farm' - a cache for the whole farm
         """
         self.request = request
         if scope == 'page_or_wiki': # XXX split and refactor later
@@ -29,6 +33,12 @@
                 filesys.makeDirs(self.arena_dir)
             else: # arena is in fact a page object
                 self.arena_dir = arena.getPagePath('cache', check_create=1)
+        elif scope == 'item': # arena is a Page instance
+            # we could move cache out of the page directory and store it to cache_dir
+            self.arena_dir = arena.getPagePath('cache', check_create=1)
+        elif scope == 'wiki':
+            self.arena_dir = os.path.join(request.cfg.cache_dir, request.cfg.siteid, arena)
+            filesys.makeDirs(self.arena_dir)
         elif scope == 'farm':
             self.arena_dir = os.path.join(request.cfg.cache_dir, '__common__', arena)
             filesys.makeDirs(self.arena_dir)