changeset 443:f2f1db293930

fix farmconfig.wikis processing for big farms (>=50 wikis) by not using a big RE for it imported from: moin--main--1.5--patch-447
author Thomas Waldmann <tw@waldmann-edv.de>
date Thu, 16 Feb 2006 16:29:03 +0000
parents 7f314352e723
children 918c58dcc275
files ChangeLog MoinMoin/multiconfig.py docs/CHANGES
diffstat 3 files changed, 37 insertions(+), 16 deletions(-) [+]
line wrap: on
line diff
--- a/ChangeLog	Wed Feb 15 23:42:47 2006 +0000
+++ b/ChangeLog	Thu Feb 16 16:29:03 2006 +0000
@@ -2,6 +2,20 @@
 # arch-tag: automatic-ChangeLog--arch@arch.thinkmo.de--2003-archives/moin--main--1.5
 #
 
+2006-02-16 17:29:03 GMT	Thomas Waldmann <tw@waldmann-edv.de>	patch-447
+
+    Summary:
+      fix farmconfig.wikis processing for big farms (>=50 wikis) by not using a big RE for it
+    Revision:
+      moin--main--1.5--patch-447
+
+    fix farmconfig.wikis processing for big farms (>=50 wikis) by not using a big RE for it
+    
+
+    modified files:
+     ChangeLog MoinMoin/multiconfig.py docs/CHANGES
+
+
 2006-02-16 00:42:47 GMT	Thomas Waldmann <tw@waldmann-edv.de>	patch-446
 
     Summary:
--- a/MoinMoin/multiconfig.py	Wed Feb 15 23:42:47 2006 +0000
+++ b/MoinMoin/multiconfig.py	Thu Feb 16 16:29:03 2006 +0000
@@ -44,14 +44,14 @@
     return module, mtime
 
 
-def _url_re():
+def _url_re_list():
     """ Return url matching regular expression
 
-    Import wikis list from farmconfig on the first call and compile a
-    regex. Later then return the cached regex.
+    Import wikis list from farmconfig on the first call and compile the
+    regexes. Later then return the cached regex list.
 
-    @rtype: compiled re object
-    @return: url to wiki config  matching re
+    @rtype: list of tuples of (name, compiled re object)
+    @return: url to wiki config name matching list
     """
     global _url_re_cache, _farmconfig_mtime
     if _url_re_cache is None:
@@ -60,12 +60,13 @@
         except ImportError:
             # Default to wikiconfig for all urls.
             _farmconfig_mtime = 0
-            _url_re_cache = re.compile(r'(?P<wikiconfig>.)')
+            _url_re_cache = [('wikiconfig', re.compile(r'.')), ] # matches everything
         else:
             try:
-                pattern = '|'.join([r'(?P<%s>%s)' % (name, regex)
-                                    for name, regex in farmconfig.wikis])
-                _url_re_cache = re.compile(pattern)
+                cache = []
+                for name, regex in farmconfig.wikis:
+                    cache.append((name, re.compile(regex)))
+                _url_re_cache = cache
             except AttributeError:
                 msg = """
 Missing required 'wikis' list in 'farmconfig.py'.
@@ -121,18 +122,18 @@
 
 def _getConfigName(url):
     """ Return config name for url or raise """
-    match = _url_re().match(url)
-    if not (match and match.groups()):
-        msg = '''
+    for name, regex in _url_re_list():
+        match = regex.match(url)
+        if match:
+            return name
+    # nothing matched
+    msg = '''
 Could not find a match for url: "%(url)s".
 
 Check your URL regular expressions in the "wikis" list in
 "farmconfig.py". 
 ''' % {'url': url}
-        raise error.ConfigurationError(msg)    
-    for name, value in match.groupdict().items():
-        if value: break
-    return name
+    raise error.ConfigurationError(msg)    
 
 
 def getConfig(url):
--- a/docs/CHANGES	Wed Feb 15 23:42:47 2006 +0000
+++ b/docs/CHANGES	Thu Feb 16 16:29:03 2006 +0000
@@ -50,6 +50,12 @@
       on every request, so it will expire cookie_lifetime after your last
       request (not after login).
     * lupy search now behaves a bit less curious. Still no guarantees...
+    * we lowered the twisted server timeout to 2 minutes now (was: 10) because
+      it just used up too many files (open TCP connections until it timeouts)
+       on our farm.
+    * the algorithm used for processing the farmconfig.wikis list was changed
+      to work for big farms (>= 50 wikis), too. This works around the python
+      "re" module limitation of having a maximum of 100 named groups in a RE.
 
 
 Version 1.5.2: