Update of /cvsroot/mailman/mailman/Mailman/Gui
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv16070

Modified Files:
      Tag: Release_2_1-maint
        Privacy.py 
Log Message:
Oops, this patch may be more modular. sorry for the bad first job.


Index: Privacy.py
===================================================================
RCS file: /cvsroot/mailman/mailman/Mailman/Gui/Privacy.py,v
retrieving revision 2.15.2.3
retrieving revision 2.15.2.4
diff -u -d -r2.15.2.3 -r2.15.2.4
--- Privacy.py  15 Sep 2004 03:18:07 -0000      2.15.2.3
+++ Privacy.py  15 Sep 2004 05:20:00 -0000      2.15.2.4
@@ -429,84 +429,87 @@
     # everything else can be done by the base class's handleForm() method.
     # However, to do this we need an awful hack.  _setValue() and
     # _getValidValue() will essentially ignore any hdrfilter_* form variables.
-    def handleForm(self, mlist, category, subcat, cgidata, doc):
-        # do this only for spam subcategory
-        if subcat == 'spam':
-            # First deal with
-            rules = []
-            # We start i at 1 and keep going until we no longer find items keyed
-            # with the marked tags.
-            i = 1
-            downi = None
-            while True:
-                deltag    = 'hdrfilter_delete_%02d' % i
-                reboxtag  = 'hdrfilter_rebox_%02d' % i
-                actiontag = 'hdrfilter_action_%02d' % i
-                wheretag  = 'hdrfilter_where_%02d' % i
-                addtag    = 'hdrfilter_add_%02d' % i
-                newtag    = 'hdrfilter_new_%02d' % i
-                uptag     = 'hdrfilter_up_%02d' % i
-                downtag   = 'hdrfilter_down_%02d' % i
-                i += 1
-                # Was this a delete?  If so, we can just ignore this entry
-                if cgidata.has_key(deltag):
-                    continue
-                # Get the data for the current box
-                pattern = cgidata.getvalue(reboxtag)
-                try:
-                    action  = int(cgidata.getvalue(actiontag))
-                    # We'll get a TypeError when the actiontag is missing and
-                    # the .getvalue() call returns None.
-                except (ValueError, TypeError):
-                    action = mm_cfg.DEFER
-                if pattern is None:
-                    # We came to the end of the boxes
-                    break
-                if cgidata.has_key(newtag) and not pattern:
-                    # This new entry is incomplete.
-                    doc.addError(_("""Header filter rules require a pattern.
-                    Incomplete filter rules will be ignored."""))
-                    continue
-                # Make sure the pattern was a legal regular expression
-                try:
-                    re.compile(pattern)
-                except (re.error, TypeError):
-                    safepattern = Utils.websafe(pattern)
-                    doc.addError(_("""The header filter rule pattern
-                    '%(safepattern)s' is not a legal regular expression.  This
-                    rule will be ignored."""))
-                    continue
-                # Was this an add item?
-                if cgidata.has_key(addtag):
-                    # Where should the new one be added?
-                    where = cgidata.getvalue(wheretag)
-                    if where == 'before':
-                        # Add a new empty rule box before the current one
-                        rules.append(('', mm_cfg.DEFER, True))
-                        rules.append((pattern, action, False))
-                        # Default is to add it after...
-                    else:
-                        rules.append((pattern, action, False))
-                        rules.append(('', mm_cfg.DEFER, True))
-                # Was this an up movement?
-                elif cgidata.has_key(uptag):
-                    # As long as this one isn't the first rule, move it up
-                    if rules:
-                        rules.insert(-1, (pattern, action, False))
-                    else:
-                        rules.append((pattern, action, False))
-                # Was this the down movement?
-                elif cgidata.has_key(downtag):
-                    downi = i - 2
+    # TK: we should call this function only in subcat == 'spam'
+    def _handleForm(self, mlist, category, subcat, cgidata, doc):
+        # First deal with
+        rules = []
+        # We start i at 1 and keep going until we no longer find items keyed
+        # with the marked tags.
+        i = 1
+        downi = None
+        while True:
+            deltag    = 'hdrfilter_delete_%02d' % i
+            reboxtag  = 'hdrfilter_rebox_%02d' % i
+            actiontag = 'hdrfilter_action_%02d' % i
+            wheretag  = 'hdrfilter_where_%02d' % i
+            addtag    = 'hdrfilter_add_%02d' % i
+            newtag    = 'hdrfilter_new_%02d' % i
+            uptag     = 'hdrfilter_up_%02d' % i
+            downtag   = 'hdrfilter_down_%02d' % i
+            i += 1
+            # Was this a delete?  If so, we can just ignore this entry
+            if cgidata.has_key(deltag):
+                continue
+            # Get the data for the current box
+            pattern = cgidata.getvalue(reboxtag)
+            try:
+                action  = int(cgidata.getvalue(actiontag))
+                # We'll get a TypeError when the actiontag is missing and the
+                # .getvalue() call returns None.
+            except (ValueError, TypeError):
+                action = mm_cfg.DEFER
+            if pattern is None:
+                # We came to the end of the boxes
+                break
+            if cgidata.has_key(newtag) and not pattern:
+                # This new entry is incomplete.
+                doc.addError(_("""Header filter rules require a pattern.
+                Incomplete filter rules will be ignored."""))
+                continue
+            # Make sure the pattern was a legal regular expression
+            try:
+                re.compile(pattern)
+            except (re.error, TypeError):
+                safepattern = Utils.websafe(pattern)
+                doc.addError(_("""The header filter rule pattern
+                '%(safepattern)s' is not a legal regular expression.  This
+                rule will be ignored."""))
+                continue
+            # Was this an add item?
+            if cgidata.has_key(addtag):
+                # Where should the new one be added?
+                where = cgidata.getvalue(wheretag)
+                if where == 'before':
+                    # Add a new empty rule box before the current one
+                    rules.append(('', mm_cfg.DEFER, True))
                     rules.append((pattern, action, False))
-                # Otherwise, just retain this one in the list
+                    # Default is to add it after...
                 else:
                     rules.append((pattern, action, False))
-            # Move any down button filter rule
-            if downi is not None:
-                rule = rules[downi]
-                del rules[downi]
-                rules.insert(downi+1, rule)
-            mlist.header_filter_rules = rules
+                    rules.append(('', mm_cfg.DEFER, True))
+            # Was this an up movement?
+            elif cgidata.has_key(uptag):
+                # As long as this one isn't the first rule, move it up
+                if rules:
+                    rules.insert(-1, (pattern, action, False))
+                else:
+                    rules.append((pattern, action, False))
+            # Was this the down movement?
+            elif cgidata.has_key(downtag):
+                downi = i - 2
+                rules.append((pattern, action, False))
+            # Otherwise, just retain this one in the list
+            else:
+                rules.append((pattern, action, False))
+        # Move any down button filter rule
+        if downi is not None:
+            rule = rules[downi]
+            del rules[downi]
+            rules.insert(downi+1, rule)
+        mlist.header_filter_rules = rules
+
+    def handleForm(self, mlist, category, subcat, cgidata, doc):
+        if subcat == 'spam':
+            self._handleForm(mlist, category, subcat, cgidata, doc)
         # Everything else is dealt with by the base handler
         GUIBase.handleForm(self, mlist, category, subcat, cgidata, doc)

_______________________________________________
Mailman-checkins mailing list
[EMAIL PROTECTED]
Unsubscribe: http://mail.python.org/mailman/options/mailman-checkins/archive%40jab.org

Reply via email to