Back to index

moin  1.9.0~rc2
Public Member Functions | Public Attributes
MoinMoin.security.autoadmin.SecurityPolicy Class Reference
Inheritance diagram for MoinMoin.security.autoadmin.SecurityPolicy:
Inheritance graph
[legend]
Collaboration diagram for MoinMoin.security.autoadmin.SecurityPolicy:
Collaboration graph
[legend]

List of all members.

Public Member Functions

def admin
def save
def __getattr__

Public Attributes

 name
 request

Detailed Description

Extend the default security policy with autoadmin feature 

Definition at line 66 of file autoadmin.py.


Member Function Documentation

def MoinMoin.security.Permissions.__getattr__ (   self,
  attr 
) [inherited]
Shortcut to export getPermission function for all known ACL rights

if attr is one of the rights in acl_rights_valid, then return a
checking function for it. Else raise an AttributeError.

@param attr: one of ACL rights as defined in acl_rights_valid
@rtype: function
@return: checking function for that right, accepting a pagename

Definition at line 137 of file __init__.py.

00137 
00138     def __getattr__(self, attr):
00139         """ Shortcut to export getPermission function for all known ACL rights
00140 
00141         if attr is one of the rights in acl_rights_valid, then return a
00142         checking function for it. Else raise an AttributeError.
00143 
00144         @param attr: one of ACL rights as defined in acl_rights_valid
00145         @rtype: function
00146         @return: checking function for that right, accepting a pagename
00147         """
00148         request = self.request
00149         if attr not in request.cfg.acl_rights_valid:
00150             raise AttributeError, attr
00151         return lambda pagename: _check(self.request, pagename, self.name, attr)
00152 
00153 
# make an alias for the default policy

Here is the call graph for this function:

def MoinMoin.security.autoadmin.SecurityPolicy.admin (   self,
  pagename 
)

Definition at line 69 of file autoadmin.py.

00069 
00070     def admin(self, pagename):
00071         try:
00072             request = self.request
00073             groups = request.groups
00074             username = request.user.name
00075             pagename = request.page.page_name
00076             mainpage = pagename.split('/')[0]
00077             if username == mainpage and username in groups.get(u'AutoAdminGroup', []):
00078                 return True
00079             group_name = "%s/AdminGroup" % mainpage
00080             if (username in groups.get(group_name, []) and
00081                 group_name in groups.get(u'AutoAdminGroup', [])):
00082                 return True
00083         except AttributeError:
00084             pass # when we get called from xmlrpc, there is no request.page
00085         return Permissions.__getattr__(self, 'admin')(pagename)

Here is the caller graph for this function:

def MoinMoin.security.autoadmin.SecurityPolicy.save (   self,
  editor,
  newtext,
  rev,
  kw 
)
Check whether user may save a page.

`editor` is the PageEditor instance, the other arguments are
those of the `PageEditor.saveText` method.

@param editor: PageEditor instance.
@param newtext: new page text, you can enable of disable saving according
    to the content of the text, e.g. prevent link spam.
@param rev: new revision number? XXX
@param kw: XXX
@rtype: bool
@return: True if you can save or False

Reimplemented from MoinMoin.security.Permissions.

Definition at line 86 of file autoadmin.py.

00086 
00087     def save(self, editor, newtext, rev, **kw):
00088         request = self.request
00089         username = request.user.name
00090         pagename = editor.page_name
00091 
00092         if grouppage_autocreate and username == pagename:
00093             # create group pages when a user saves his own homepage
00094             for page in grouppages:
00095                 grouppagename = "%s/%s" % (username, page)
00096                 grouppage = Page(request, grouppagename)
00097                 if not grouppage.exists():
00098                     text = """\
00099 #acl %(username)s:read,write,delete,revert
00100  * %(username)s
00101 """ % locals()
00102                     editor = PageEditor(request, grouppagename)
00103                     editor._write_file(text)
00104 
00105         parts = pagename.split('/')
00106         if len(parts) == 2:
00107             subpage = parts[1]
00108             if subpage in grouppages and not self.admin(pagename):
00109                 return False
00110 
00111         # No problem to save if my base class agrees
00112         return Permissions.save(self, editor, newtext, rev, **kw)
00113 
00114 

Here is the call graph for this function:

Here is the caller graph for this function:


Member Data Documentation

Definition at line 118 of file __init__.py.

Definition at line 119 of file __init__.py.


The documentation for this class was generated from the following file: