comparison MoinMoin/security.py @ 0:77665d8e2254

tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0 (automatically generated log message) imported from: moin--main--1.5--base-0
author Thomas Waldmann <tw-public@gmx.de>
date Thu, 22 Sep 2005 15:09:50 +0000
parents
children
comparison
equal deleted inserted replaced
-1:000000000000 0:77665d8e2254
1 # -*- coding: iso-8859-1 -*-
2 """
3 MoinMoin - Wiki Security Interface
4
5 This implements the basic interface for user permissions and
6 system policy. If you want to define your own policy, inherit
7 from the base class 'Permissions', so that when new permissions
8 are defined, you get the defaults.
9
10 Then assign your new class to "SecurityPolicy" in wikiconfig;
11 and I mean the class, not an instance of it!
12
13 @copyright: 2000-2004 by Jürgen Hermann <jh@web.de>
14 @license: GNU GPL, see COPYING for details.
15 """
16
17 #############################################################################
18 ### Basic Permissions Interface -- most features enabled by default
19 #############################################################################
20
21
22 class Permissions:
23 """ Basic interface for user permissions and system policy.
24
25 Note that you still need to allow some of the related actions, this
26 just controls their behaviour, not their activation.
27 """
28
29 def __init__(self, user):
30 """ Calculate the permissons `user` has.
31 """
32 from MoinMoin.Page import Page
33 self.Page = Page
34 self.name = user.name
35 self.request = user._request
36
37 def save(self, editor, newtext, rev, **kw):
38 """ Check whether user may save a page.
39
40 `editor` is the PageEditor instance, the other arguments are
41 those of the `PageEditor.saveText` method.
42 """
43 return self.write(editor.page_name)
44
45 def __getattr__(self, attr):
46 """ if attr is one of the rights in acl_rights_valid, then return a
47 checking function for it. Else raise an error.
48 """
49 request = self.request
50 Page = self.Page
51 if attr in request.cfg.acl_rights_valid:
52 return lambda pagename, Page=Page, request=request, attr=attr: Page(request, pagename).getACL(request).may(request, self.name, attr)
53 else:
54 raise AttributeError, attr
55
56
57 # make an alias for the default policy
58 Default = Permissions
59