Description

I do have some problems using xmlrpc on a restricted wiki. It looks like applyAuthToken fails

wikiconfig.py has these lines

actions_excluded = []
acl_rights_default = u"TestUser:read,write,delete,revert,admin"

I do have created a user TestUser and a TestPage on my wiki.

   1 #!/usr/bin/env python
   2 # -*- coding: iso-8859-1 -*-
   3 import xmlrpclib
   4 from MoinMoin.request import request_cli
   5 
   6 name = u"TestUser"
   7 pagename = u'TestPage'
   8 password = u"the_secret_password"
   9 wikiurl = "http://localhost:8080"
  10 homewiki = xmlrpclib.ServerProxy(wikiurl + "?action=xmlrpc2",
  11                                  allow_none=True)
  12 auth_token = homewiki.getAuthToken(name, password)
  13 print auth_token
  14 dummy = homewiki.applyAuthToken(auth_token)
  15 print dummy
  16 attachname = 'beispiel.txt'
  17 text = file(attachname, 'rb+').read()
  18 data = xmlrpclib.Binary(text)
  19 homewiki.putAttachment(pagename, attachname, data) 

result

fho...

SUCCESS

xmlrpclib.Fault: <Fault 1: 'You are not allowed to read this page.'>

Additional script for testing the user

   1 #!/usr/bin/env python
   2 # -*- coding: iso-8859-1 -*-
   3 from MoinMoin.user import User
   4 from MoinMoin.request import request_cli
   5 request = request_cli.Request()
   6 name = u"TestUser"
   7 user = User(request, name=name)
   8 user.valid = 1
   9 
  10 pagename = u'TestPage'
  11 print user.may.read(pagename)

result

True

Steps to reproduce

see above

Example

see above

Component selection

Details

MoinMoin Version

1.6.0beta1

OS and Version

Python Version

Server Setup

Server Details

Language you are using the wiki in (set in the browser/UserPreferences)

Workaround

Discussion

Looks like the first script does not need request. But you need to do the xmlrpc calls in a single multicall. The first script looks incomplete (what triggers the fault?).

yeah, thats it

   1 auth_token = homewiki.getAuthToken(name, password)
   2 mc = xmlrpclib.MultiCall(homewiki)
   3 mc.applyAuthToken(auth_token)
   4 attachname = 'beispiel.txt'
   5 text = file(attachname, 'rb+').read()
   6 data = xmlrpclib.Binary(text)
   7 mc.putAttachment(pagename, attachname, data)
   8 result = mc()

This isn't a bug, you need to use multiCall when using authentication. When you call putAttachment there are no credentials in the request so it fails. Multicall sends the auth token and attachment together in one xmlrpc request.

Plan


CategoryMoinMoinNoBug

MoinMoin: MoinMoinBugs/xmlrpc_and_getAuthToken (last edited 2009-07-02 06:19:16 by 222)