changeset 1550:a4f0632414da

using request.cfg.cache more
author Thomas Waldmann <tw AT waldmann-edv DOT de>
date Thu, 14 Sep 2006 22:49:42 +0200
parents e36313297589
children 0d2f2d531e81
files MoinMoin/Page.py MoinMoin/action/__init__.py MoinMoin/macro/__init__.py MoinMoin/request/__init__.py MoinMoin/security/antispam.py MoinMoin/user.py MoinMoin/wikidicts.py MoinMoin/wikiutil.py
diffstat 8 files changed, 27 insertions(+), 31 deletions(-) [+]
line wrap: on
line diff
--- a/MoinMoin/Page.py	Thu Sep 14 22:08:45 2006 +0200
+++ b/MoinMoin/Page.py	Thu Sep 14 22:49:42 2006 +0200
@@ -1633,13 +1633,13 @@
         currentRevision = self.current_rev()
         key = self.page_name
         try:
-            aclRevision, acl = request.cfg._acl_cache.get(key, (None, None))
+            aclRevision, acl = request.cfg.cache.acl.get(key, (None, None))
         except AttributeError:
-            request.cfg._acl_cache = {}
+            request.cfg.cache.acl = {}
             aclRevision, acl = None, None
         if aclRevision != currentRevision:
             acl = self.parseACL()
-            request.cfg._acl_cache[key] = (currentRevision, acl)
+            request.cfg.cache.acl[key] = (currentRevision, acl)
         request.clock.stop('getACL')
         return acl
 
@@ -1667,11 +1667,11 @@
         request = self.request
         key = self.page_name
         try:
-            del request.cfg._acl_cache[key]
+            del request.cfg.cache.acl[key]
         except KeyError:
             pass
         except AttributeError:
-            request.cfg._acl_cache = {}
+            request.cfg.cache.acl = {}
 
     # Text format -------------------------------------------------------
 
--- a/MoinMoin/action/__init__.py	Thu Sep 14 22:08:45 2006 +0200
+++ b/MoinMoin/action/__init__.py	Thu Sep 14 22:49:42 2006 +0200
@@ -288,13 +288,11 @@
 
 # Dispatching ----------------------------------------------------------------
 def getNames(cfg):
-    if hasattr(cfg, 'action_names'):
-        return cfg.action_names
-    else:
+    if not hasattr(cfg.cache, 'action_names'):
         lnames = names[:]
         lnames.extend(wikiutil.getPlugins('action', cfg))
-        cfg.action_names = lnames # remember it
-        return lnames
+        cfg.cache.action_names = lnames # remember it
+    return cfg.cache.action_names
 
 def getHandler(request, action, identifier="execute"):
     """ return a handler function for a given action or None """
--- a/MoinMoin/macro/__init__.py	Thu Sep 14 22:08:45 2006 +0200
+++ b/MoinMoin/macro/__init__.py	Thu Sep 14 22:49:42 2006 +0200
@@ -37,14 +37,12 @@
 #############################################################################
 
 def getNames(cfg):
-    if hasattr(cfg, 'macro_names'):
-        return cfg.macro_names
-    else:
+    if not hasattr(cfg.cache, 'macro_names'):
         lnames = names[:]
         lnames.extend(i18n.wikiLanguages().keys())
         lnames.extend(wikiutil.getPlugins('macro', cfg))
-        cfg.macro_names = lnames # remember it
-        return lnames
+        cfg.cache.macro_names = lnames # remember it
+    return cfg.cache.macro_names
 
 
 #############################################################################
--- a/MoinMoin/request/__init__.py	Thu Sep 14 22:08:45 2006 +0200
+++ b/MoinMoin/request/__init__.py	Thu Sep 14 22:49:42 2006 +0200
@@ -680,13 +680,13 @@
         @return: dict of all known actions
         """
         try:
-            self.cfg._known_actions # check
+            self.cfg.cache.known_actions # check
         except AttributeError:
             from MoinMoin import action
-            self.cfg._known_actions = set(action.getNames(self.cfg))
+            self.cfg.cache.known_actions = set(action.getNames(self.cfg))
 
         # Return a copy, so clients will not change the set.
-        return self.cfg._known_actions.copy()
+        return self.cfg.cache.known_actions.copy()
 
     def getAvailableActions(self, page):
         """ Get list of avaiable actions for this request
--- a/MoinMoin/security/antispam.py	Thu Sep 14 22:08:45 2006 +0200
+++ b/MoinMoin/security/antispam.py	Thu Sep 14 22:49:42 2006 +0200
@@ -162,7 +162,7 @@
             request.clock.start('antispam')
 
             blacklist = []
-            invalidate_cache = not getattr(request.cfg, "_mmblcache", None)
+            invalidate_cache = not getattr(request.cfg.cache, "antispam_blacklist", None)
             for pn in BLACKLISTPAGES:
                 do_update = (pn != "LocalBadContent")
                 invalidate_cache_necessary, blacklist_entries = getblacklist(request, pn, do_update)
@@ -178,7 +178,7 @@
                         except re.error, err:
                             dprint("Error in regex '%s': %s. Please check the pages %s." % (blacklist_re, str(err), ', '.join(BLACKLISTPAGES)))
                             continue
-                    request.cfg._mmblcache = mmblcache
+                    request.cfg.cache.antispam_blacklist = mmblcache
 
                 from MoinMoin.Page import Page
 
@@ -192,7 +192,7 @@
                 difference = newset.difference(oldset)
                 addedtext = ''.join(difference)
 
-                for blacklist_re in request.cfg._mmblcache:
+                for blacklist_re in request.cfg.cache.antispam_blacklist:
                     match = blacklist_re.search(addedtext)
                     if match:
                         # Log error and raise SaveError, PageEditor
--- a/MoinMoin/user.py	Thu Sep 14 22:08:45 2006 +0200
+++ b/MoinMoin/user.py	Thu Sep 14 22:49:42 2006 +0200
@@ -56,7 +56,7 @@
         return None
     cfg = request.cfg
     try:
-        _name2id = cfg._name2id
+        _name2id = cfg.cache.name2id
     except AttributeError:
         arena = 'user'
         key = 'name2id'
@@ -65,13 +65,13 @@
             _name2id = pickle.loads(cache.content())
         except (pickle.UnpicklingError, IOError, EOFError, ValueError):
             _name2id = {}
-        cfg._name2id = _name2id
+        cfg.cache.name2id = _name2id
     id = _name2id.get(searchName, None)
     if id is None:
         for userid in getUserList(request):
             name = User(request, id=userid).name
             _name2id[name] = userid
-        cfg._name2id = _name2id
+        cfg.cache.name2id = _name2id
         arena = 'user'
         key = 'name2id'
         cache = caching.CacheEntry(request, arena, key, scope='wiki')
--- a/MoinMoin/wikidicts.py	Thu Sep 14 22:08:45 2006 +0200
+++ b/MoinMoin/wikidicts.py	Thu Sep 14 22:49:42 2006 +0200
@@ -322,7 +322,7 @@
         arena = 'wikidicts'
         key = 'dicts_groups'
         try:
-            self.__dict__.update(self.cfg.DICTS_DATA)
+            self.__dict__.update(self.cfg.cache.DICTS_DATA)
         except AttributeError:
             try:
                 cache = caching.CacheEntry(request, arena, key, scope='wiki')
@@ -350,7 +350,7 @@
 
                 # remove old entries when dict or group page have been deleted,
                 # add entries when pages have been added
-                # use copies because the dicts are shared via cfg.DICTS_DATA
+                # use copies because the dicts are shared via cfg.cache.DICTS_DATA
                 #  and must not be modified
                 olddictdict = self.dictdict.copy()
                 oldgroupdict = self.groupdict.copy()
@@ -415,5 +415,5 @@
             cache.update(pickle.dumps(data, PICKLE_PROTOCOL))
 
         # remember it (persistent environments)
-        self.cfg.DICTS_DATA = data
+        self.cfg.cache.DICTS_DATA = data
 
--- a/MoinMoin/wikiutil.py	Thu Sep 14 22:08:45 2006 +0200
+++ b/MoinMoin/wikiutil.py	Thu Sep 14 22:49:42 2006 +0200
@@ -1148,7 +1148,7 @@
     @rtype: class, None
     @returns: the parser class or None
     """
-    if not hasattr(cfg, '_EXT_TO_PARSER'):
+    if not hasattr(cfg.cache, 'EXT_TO_PARSER'):
         etp, etd = {}, None
         for pname in getPlugins('parser', cfg):
             try:
@@ -1162,10 +1162,10 @@
                         etp[ext] = Parser
                 elif str(exts) == '*':
                     etd = Parser
-        cfg._EXT_TO_PARSER = etp
-        cfg._EXT_TO_PARSER_DEFAULT = etd
+        cfg.cache.EXT_TO_PARSER = etp
+        cfg.cache.EXT_TO_PARSER_DEFAULT = etd
 
-    return cfg._EXT_TO_PARSER.get(extension, cfg._EXT_TO_PARSER_DEFAULT)
+    return cfg.cache.EXT_TO_PARSER.get(extension, cfg.cache.EXT_TO_PARSER_DEFAULT)
 
 
 #############################################################################