Back to index

moin  1.9.0~rc2
Functions | Variables
MoinMoin.script.old.xmlrpc-tools.UpdateGroupTest Namespace Reference

Functions

def updateGroup

Variables

string server_url = "http://master.moinmo.in/?action=xmlrpc2"
string username = "ThomasWaldmann"
string password = "wrong"
string groupname = u"TestGroup"
string groupdesc = u"Just a test group"
list groupmembers = [u'JoeDoe', u'JaneDoe', ]
string acl = "All:read,write,delete"

Function Documentation

def MoinMoin.script.old.xmlrpc-tools.UpdateGroupTest.updateGroup (   server_url,
  username,
  password,
  groupname,
  groupdesc,
  groupmembers,
  acl = '' 
)
Update a Wiki Group Page named <groupname> with a list of <groupmembers> via xmlrpc.
Contact the target wiki xmlrpc service at <server_url> and use <username>
and <password> to authenticate as wiki user there.

@param server_url: xmlrpc service url of target wiki (str)
@param username: username used to authenticate at server_url wiki (unicode)
@param password: password of <username> (unicode)
@param groupname: group page name (unicode)
@param groupdesc: group description (unicode)
@param groupmembers: group member names (list of unicode)
@param acl: Access Control List value (optional, unicode)

Definition at line 20 of file UpdateGroupTest.py.

00020 
00021 def updateGroup(server_url, username, password, groupname, groupdesc, groupmembers, acl=''):
00022     """
00023     Update a Wiki Group Page named <groupname> with a list of <groupmembers> via xmlrpc.
00024     Contact the target wiki xmlrpc service at <server_url> and use <username>
00025     and <password> to authenticate as wiki user there.
00026 
00027     @param server_url: xmlrpc service url of target wiki (str)
00028     @param username: username used to authenticate at server_url wiki (unicode)
00029     @param password: password of <username> (unicode)
00030     @param groupname: group page name (unicode)
00031     @param groupdesc: group description (unicode)
00032     @param groupmembers: group member names (list of unicode)
00033     @param acl: Access Control List value (optional, unicode)
00034     """
00035     wiki = xmlrpclib.ServerProxy(server_url)
00036     auth_token = wiki.getAuthToken(username, password)
00037     assert auth_token, 'Invalid username/password'
00038 
00039     # Verify that the token is valid by using it
00040     # and checking that the result is 'SUCCESS'.
00041     # The token should be valid for 15 minutes.
00042     assert wiki.applyAuthToken(auth_token) == 'SUCCESS'
00043 
00044     try:
00045         # build a multicall object that
00046         mcall = xmlrpclib.MultiCall(wiki)
00047         # first applies the token and
00048         mcall.applyAuthToken(auth_token)
00049         # then creates/updates the group page
00050         mcall.UpdateGroup(groupname, groupdesc, groupmembers, acl)
00051         # now execute the multicall
00052         results = mcall()
00053 
00054         # everything should have worked
00055         # instead of the asserts you can have anything else
00056         # but you should definitely access all the results
00057         # once so that faults are checked and raised
00058         assert results[0] == 'SUCCESS'
00059         # TODO: process other results / xmlrpc faults
00060     finally:
00061         # be nice to the server and clean up the token
00062         # regardless of what happened
00063         assert wiki.deleteAuthToken(auth_token) == 'SUCCESS'
00064 


Variable Documentation

string MoinMoin.script.old.xmlrpc-tools.UpdateGroupTest.acl = "All:read,write,delete"

Definition at line 76 of file UpdateGroupTest.py.

string MoinMoin.script.old.xmlrpc-tools.UpdateGroupTest.groupdesc = u"Just a test group"

Definition at line 74 of file UpdateGroupTest.py.

list MoinMoin.script.old.xmlrpc-tools.UpdateGroupTest.groupmembers = [u'JoeDoe', u'JaneDoe', ]

Definition at line 75 of file UpdateGroupTest.py.

string MoinMoin.script.old.xmlrpc-tools.UpdateGroupTest.groupname = u"TestGroup"

Definition at line 73 of file UpdateGroupTest.py.

string MoinMoin.script.old.xmlrpc-tools.UpdateGroupTest.password = "wrong"

Definition at line 70 of file UpdateGroupTest.py.

string MoinMoin.script.old.xmlrpc-tools.UpdateGroupTest.server_url = "http://master.moinmo.in/?action=xmlrpc2"

Definition at line 67 of file UpdateGroupTest.py.

string MoinMoin.script.old.xmlrpc-tools.UpdateGroupTest.username = "ThomasWaldmann"

Definition at line 69 of file UpdateGroupTest.py.