<html><head><meta name="color-scheme" content="light dark"></head><body><pre style="word-wrap: break-word; white-space: pre-wrap;">* looking for arch@arch.thinkmo.de--2003-archives/moin--main--1.5--patch-376 to compare with
* comparing to arch@arch.thinkmo.de--2003-archives/moin--main--1.5--patch-376
M  MoinMoin/multiconfig.py
M  MoinMoin/security.py
A  MoinMoin/securityrule.py

* modified files

--- orig/MoinMoin/multiconfig.py
+++ mod/MoinMoin/multiconfig.py
@@ -10,6 +10,8 @@
 from MoinMoin import error
 import MoinMoin.auth as authmodule
 
+import MoinMoin.securityrule as SecurityRule
+
 _url_re_cache = None
 _farmconfig_mtime = None
 _config_cache = {}
@@ -168,6 +170,7 @@
     acl_rights_before = u""
     acl_rights_after = u""
     acl_rights_valid = ['read', 'write', 'delete', 'revert', 'admin']
+    security_rules = [] #Test: security_rules = [{'rule' :SecurityRule.vaild_user, "is_non": 1, "write": 0}]
     
     actions_excluded = [] # ['DeletePage', 'AttachFile', 'RenamePage']
     allow_xslt = 0


--- orig/MoinMoin/security.py
+++ mod/MoinMoin/security.py
@@ -43,11 +43,26 @@
         return self.write(editor.page_name)
 
     def __getattr__(self, attr):
-        """ if attr is one of the rights in acl_rights_valid, then return a
-            checking function for it. Else raise an error.
-        """
         request = self.request
         Page = self.Page
+
+        # check right in security_rules
+        for s in request.cfg.security_rules:
+            # Make Sure the SecurityRules have 'rule' and 'is_non'
+            # and the SecurityRules is a Dict.
+            try:
+                if s.has_key('rule') and s.has_key('is_non'):
+                   valid_security_rule = 1
+            except AttributeError:
+                valid_security_rule = 0
+            if valid_security_rule:
+                sr = s['rule']
+                security_rule = sr(request.user, s)
+                attr_security_rule = getattr(security_rule, attr, 0)
+                if attr_security_rule:
+                    return lambda pagename, **kw: attr_security_rule(pagename, **kw)
+
+        # If cann't check in security_rules, try it in moin_acl
         if attr in request.cfg.acl_rights_valid:
             return lambda pagename, Page=Page, request=request, attr=attr: Page(request, pagename).getACL(request).may(request, self.name, attr)
         else:


--- orig/MoinMoin/securityrule.py
+++ mod/MoinMoin/securityrule.py
@@ -0,0 +1,49 @@
+# -*- coding: iso-8859-1 -*-
+"""
+@copyright: (c) Bastian Blank, Florian Festi, Thomas Waldmann
+@copyright: MoinMoin:FrankieChow
+@license: GNU GPL, see COPYING for details.
+"""
+
+class security_rules_obj:
+    """ Template of SecurityRules Object
+    """
+
+    def __init__(self, user, dict):
+        """ Calculate the permissons `user` has.
+        """
+        self.user = user
+        self.name = user.name
+        self.request = user._request
+        self.dict = dict
+        is_non = self.dict['is_non']
+        # FixMe: What about this logic relationship
+        if is_non and self.check_rule():
+             self.rule_result = 1
+        elif is_non and not self.check_rule():
+             self.rule_result = 0
+        elif not is_non and self.check_rule():
+             self.rule_result = 0
+        elif not is_non and not self.check_rule():
+             self.rule_result = 1
+
+    def true(self, pagename, **kw):
+        return 1
+    def false(self, pagename, **kw):
+        return 0
+
+    def __getattr__(self, attr):
+        if not self.rule_result: raise AttributeError, attr
+        if self.dict.has_key(attr):
+            if self.dict[attr]:
+                return lambda pagename, **kw: self.true(pagename, **kw)
+            else:
+                return lambda pagename, **kw: self.false(pagename, **kw)
+        else: raise AttributeError, attr
+
+class vaild_user(security_rules_obj):
+    def check_rule(self):
+        if self.user.valid:
+            return 1
+        else:
+            return 0
</pre></body></html>