Attachment 'split-before-after.diff'
Download 1 * looking for arch@arch.thinkmo.de--2003-archives/moin--main--1.3--patch-556 to compare with
2 * comparing to arch@arch.thinkmo.de--2003-archives/moin--main--1.3--patch-556
3 M MoinMoin/multiconfig.py
4 M MoinMoin/wikiacl.py
5
6 * modified files
7
8 --- orig/MoinMoin/multiconfig.py
9 +++ mod/MoinMoin/multiconfig.py
10 @@ -321,6 +321,13 @@
11 # e.g u'%(page_front_page)s' % self
12 self.navi_bar = [elem % self for elem in self.navi_bar]
13
14 + # precompile acl strings
15 + if self.acl_enabled:
16 + from wikiacl import AccessControlList
17 + self.acl_default = AccessControlList(None, self.acl_rights_default, cfg=self)
18 + self.acl_before = AccessControlList(None, self.acl_rights_before, cfg=self, default=True)
19 + self.acl_after = AccessControlList(None, self.acl_rights_after, cfg=self, default=True)
20 +
21 def _config_check(self):
22 """ Check namespace and warn about unknown names
23
24
25
26 --- orig/MoinMoin/wikiacl.py
27 +++ mod/MoinMoin/wikiacl.py
28 @@ -113,33 +113,25 @@
29
30 special_users = ["All", "Known", "Trusted"]
31
32 - def __init__(self, request, lines=[]):
33 + def __init__(self, request, lines=[], cfg=None, default=False):
34 """Initialize an ACL, starting from <nothing>.
35 """
36 - self.setLines(request.cfg, lines)
37 + self.is_default = default
38 + if cfg is not None:
39 + self.setLines(cfg, lines)
40 + else:
41 + self.setLines(request.cfg, lines)
42
43 def setLines(self, cfg, lines=[]):
44 self.clean()
45 - self.addBefore(cfg)
46 - if not lines:
47 - self.addDefault(cfg)
48 - else:
49 - for line in lines:
50 - self.addLine(cfg, line)
51 - self.addAfter(cfg)
52 + for line in lines:
53 + self.addLine(cfg, line)
54
55 def clean(self):
56 self.acl = [] # [ ('User', {"read": 0, ...}), ... ]
57 self.acl_lines = []
58 self._is_group = {}
59
60 - def addBefore(self, cfg):
61 - self.addLine(cfg, cfg.acl_rights_before, remember=0)
62 - def addDefault(self, cfg):
63 - self.addLine(cfg, cfg.acl_rights_default, remember=0)
64 - def addAfter(self, cfg):
65 - self.addLine(cfg, cfg.acl_rights_after, remember=0)
66 -
67 def addLine(self, cfg, aclstring, remember=1):
68 """ Add another ACL line
69
70 @@ -199,7 +191,12 @@
71
72 is_group_member = request.dicts.has_member
73
74 - allowed = None
75 + if self.is_default:
76 + allowed = None
77 + else:
78 + allowed = request.cfg.acl_before.may(request, name, dowhat)
79 + if allowed is not None:
80 + return allowed
81 for entry, rightsdict in self.acl:
82 if entry in self.special_users:
83 handler = getattr(self, "_special_"+entry, None)
84 @@ -210,7 +207,9 @@
85 allowed = rightsdict.get(dowhat)
86 if allowed is not None:
87 return allowed
88 - return 0
89 + if self.is_default:
90 + return allowed
91 + return request.cfg.acl_after.may(request, name, dowhat)
92
93 def getString(self, b='#acl ', e='\n'):
94 """print the acl strings we were fed with"""
95 @@ -355,5 +354,7 @@
96 else:
97 args = ""
98 acl_lines.append(args)
99 + if not acl_lines:
100 + return request.cfg.acl_default
101 return AccessControlList(request, acl_lines)
102
Attached Files
To refer to attachments on a page, use attachment:filename, as shown below in the list of files. Do NOT use the URL of the [get] link, since this is subject to change and can break easily.You are not allowed to attach a file to this page.