changeset 3730:4204677846cb

merge main
author Johannes Berg <johannes AT sipsolutions DOT net>
date Sat, 21 Jun 2008 13:00:46 +0200
parents bba0d3392918 (current diff) fef3c5039997 (diff)
children 1976b1fdabd0 9b64ad3c2aee
files
diffstat 1 files changed, 6 insertions(+), 13 deletions(-) [+]
line wrap: on
line diff
--- a/MoinMoin/wikidicts.py	Sat Jun 21 12:59:17 2008 +0200
+++ b/MoinMoin/wikidicts.py	Sat Jun 21 13:00:46 2008 +0200
@@ -26,18 +26,12 @@
         if request is not None and pagename is not None:
             self.loadFromPage(request, pagename)
 
-    # Regular expression used to parse text - subclass should override this
-    regex = u''
-    def initRegex(cls):
-        """ Make it a class attribute to avoid it being pickled. """
-        if isinstance(cls.regex, unicode):  # not compiled yet
-            cls.regex = re.compile(cls.regex, re.MULTILINE | re.UNICODE)
-    initRegex = classmethod(initRegex)
+    # Regular expression used to parse text - subclass must override this
+    regex = None  # re.compile(u'...', re.MULTILINE | re.UNICODE)
 
     def loadFromPage(self, request, name):
         """ load the dict from wiki page <name>'s content """
         self.name = name
-        self.initRegex()
         text = Page.Page(request, name).get_raw_body()
         self.initFromText(text)
 
@@ -59,8 +53,8 @@
         keyn:: ....
        any text ignored
     """
-    # Key:: Value - ignore all but key:: value pairs, strip whitespace
-    regex = ur'^ (?P<key>.+?):: (?P<val>.*?) *$' # exactly one space after the :: is required
+    # Key:: Value - ignore all but key:: value pairs, strip whitespace, exactly one space after the :: is required
+    regex = re.compile(ur'^ (?P<key>.+?):: (?P<val>.*?) *$', re.MULTILINE | re.UNICODE)
 
     def initFromText(self, text):
         for match in self.regex.finditer(text):
@@ -87,9 +81,8 @@
     If there are any free links using [[free link]] notation, the markup
     is stripped from the member.
     """
-    # * Member - ignore all but first level list items, strip whitespace,
-    # strip free links markup if exists.
-    regex = ur'^ \* +(?:\[\[)?(?P<member>.+?)(?:\]\])? *$'
+    # * Member - ignore all but first level list items, strip whitespace, strip free links markup
+    regex = re.compile(ur'^ \* +(?:\[\[)?(?P<member>.+?)(?:\]\])? *$', re.MULTILINE | re.UNICODE)
 
     def __init__(self, request=None, pagename=None):
         self._list = []