Attachment 'securityrule.py'

Download

   1 # -*- coding: iso-8859-1 -*-
   2 """
   3 @copyright: (c) Bastian Blank, Florian Festi, Thomas Waldmann
   4 @copyright: MoinMoin:FrankieChow
   5 @license: GNU GPL, see COPYING for details.
   6 """
   7 
   8 class security_rules_obj:
   9     """ Template of SecurityRules Object
  10     """
  11 
  12     def __init__(self, user, dict):
  13         """ Calculate the permissons `user` has.
  14         """
  15         self.user = user
  16         self.name = user.name
  17         self.request = user._request
  18         self.dict = dict
  19 
  20     def cal_rule_result(self):
  21         """ Cal the dict('is_non') and set the rule_result.
  22         """
  23         if self.dict.has_key('is_non'):
  24             self.rule_result = self.dict['is_non'] * self.match_rule()
  25         else:
  26             self.rule_result = self.match_rule()
  27 
  28     def check_dict(self):
  29         """
  30         Developer can override it to check pass dict.
  31         """
  32         self.cal_rule_result()
  33         if getattr(self, attr, 0):
  34             return 1
  35 
  36     def true(self, pagename, **kw):
  37         return 1
  38     def false(self, pagename, **kw):
  39         return 0
  40 
  41     def __getattr__(self, attr):
  42         if not self.rule_result: raise AttributeError, attr
  43         if self.dict[attr]:
  44             return lambda pagename, **kw: self.true(pagename, **kw)
  45         else:
  46             return lambda pagename, **kw: self.false(pagename, **kw)
  47 
  48 class vaild_user(security_rules_obj):
  49     """
  50     Maybe Developer must need to write this module.
  51     """
  52     def match_rule(self):
  53         if self.user.valid:
  54             return 1
  55         else:
  56             return 0

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.
  • [get | view] (2006-01-18 08:53:17, 2.7 KB) [[attachment:security.py]]
  • [get | view] (2006-01-18 08:53:47, 1.5 KB) [[attachment:securityrule.py]]
  • [get | view] (2006-01-14 05:42:23, 79.3 KB) [[attachment:sr.png]]
  • [get | view] (2006-01-18 08:52:39, 28.8 KB) [[attachment:sr.svg]]
 All files | Selected Files: delete move to page copy to page

You are not allowed to attach a file to this page.