equal
deleted
inserted
replaced
25 for k, m in matchers: |
25 for k, m in matchers: |
26 if k not in kw or not m(kw[k]): |
26 if k not in kw or not m(kw[k]): |
27 return False |
27 return False |
28 return True |
28 return True |
29 return c |
29 return c |
30 |
|
31 class AccessException(Exception): |
|
32 pass |
|
33 |
30 |
34 class Ruleset(object): |
31 class Ruleset(object): |
35 '''Class representing the rules in a rule file''' |
32 '''Class representing the rules in a rule file''' |
36 |
33 |
37 levels = ["init", "write", "read", "deny"] |
34 levels = ["init", "write", "read", "deny"] |
59 |
56 |
60 def allow(self, level, **kw): |
57 def allow(self, level, **kw): |
61 a = self.matchrule(kw) |
58 a = self.matchrule(kw) |
62 return a in self.levels and self.levels.index(a) <= self.levels.index(level) |
59 return a in self.levels and self.levels.index(a) <= self.levels.index(level) |
63 |
60 |
64 def check(self, level, **kw): |
|
65 if not self.allow(level, **kw): |
|
66 raise AccessException() |
|
67 |
|
68 def readfile(self, fn): |
61 def readfile(self, fn): |
69 try: |
62 try: |
70 f = open(fn) |
63 f = open(fn) |
71 try: |
64 try: |
72 for l in f: |
65 for l in f: |