Back to index

moin  1.9.0~rc2
Functions | Variables
MoinMoin.xmlrpc.UpdateGroup Namespace Reference

Functions

def execute

Variables

tuple logging = log.getLogger(__name__)

Function Documentation

def MoinMoin.xmlrpc.UpdateGroup.execute (   self,
  groupname,
  groupcomment,
  memberlist,
  pageacls = u"All:read" 
)
create or overwrite a group definition page
@param groupname: the page name of the group definition page (unicode or utf-8)
                  must match the page_group_regex or it won't have effect
@param memberlist: the group members (unicode or utf-8)
@param pageacls: the ACLs to use for the group page (defaults to u"All:read")
@rtype: bool
@return: true on success

Definition at line 16 of file UpdateGroup.py.

00016 
00017 def execute(self, groupname, groupcomment, memberlist, pageacls=u"All:read"):
00018     """
00019     create or overwrite a group definition page
00020     @param groupname: the page name of the group definition page (unicode or utf-8)
00021                       must match the page_group_regex or it won't have effect
00022     @param memberlist: the group members (unicode or utf-8)
00023     @param pageacls: the ACLs to use for the group page (defaults to u"All:read")
00024     @rtype: bool
00025     @return: true on success
00026     """
00027 
00028     pagename = self._instr(groupname)
00029 
00030     # also check ACLs
00031     if not self.request.user.may.write(pagename):
00032         return xmlrpclib.Fault(1, "You are not allowed to edit this page")
00033 
00034     # check if groupname matches page_group_regex
00035     if not self.request.cfg.cache.page_group_regexact.search(groupname):
00036         return xmlrpclib.Fault(2, "The groupname %s does not match your page_group_regex (%s)" % (
00037                                groupname, self.request.cfg.page_group_regex))
00038 
00039     newtext = """\
00040 #acl %(acl)s
00041 %(comment)s
00042 %(memberlist)s
00043 """ % {
00044     'acl': pageacls,
00045     'comment': groupcomment,
00046     'memberlist': "\n * ".join([''] + memberlist)
00047     }
00048 
00049     page = PageEditor(self.request, pagename)
00050     try:
00051         msg = page.saveText(newtext, 0)
00052     except page.SaveError, msg:
00053         logging.error("SaveError msg: %s" % str(msg))
00054         return xmlrpclib.Fault(3, msg)
00055     if msg:
00056         logging.debug("saveText msg: %s" % msg)
00057 
00058     #we need this to update pagelinks cache:
00059     #self.request.args = self.request.form = self.request.setup_args()
00060     self.request.redirectedOutput(page.send_page, content_only=1)
00061 
00062     return xmlrpclib.Boolean(1)
00063 

Variable Documentation

Definition at line 12 of file UpdateGroup.py.