nausheenfatma / python-wikitools

Automatically exported from code.google.com/p/python-wikitools
0 stars 0 forks source link

Cannot create/edit pages #49

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 8 years ago
What steps will reproduce the problem?
1. Import wikitools and login
2. Verify that everything is working by searching for "Main Page":
>>> params = {'action':'query', 'titles':'Main Page'}
>>> request = wikitools.api.APIRequest(a, params)
>>> result = request.query()
>>> result
{u'query': {u'pages': {u'1': {u'ns': 0, u'pageid': 1, u'title': u'Main Page'}}}}

3. Attempt to edit a page:
>>> params = {'action':'edit', 'title':'Sandbox', "text":"Hello, API"}
>>> request = wikitools.api.APIRequest(a, params)
>>> result = request.query()
^[[ATraceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/usr/local/lib/python2.7/dist-packages/wikitools/api.py", line 143, in query
    raise APIError(data['error']['code'], data['error']['info'])
wikitools.api.APIError: (u'notoken', u'The token parameter must be set')

What is the expected output? What do you see instead?
Expected: The page should be edited
Actual: wikitools.api.APIError: (u'notoken', u'The token parameter must be set')

What version of the product are you using? On what operating system?
1.1.1 (i believe. I installed it today with easy_install) on Ubuntu 11.10

Please provide any additional information below.
Perhaps I'm doing something wrong, but there doesn't seem to be anything in any 
documentation about this.

Original issue reported on code.google.com by thefin...@gmail.com on 5 Mar 2012 at 10:34

GoogleCodeExporter commented 8 years ago
If you want to do edit requests directly to the API you need to get and supply 
an edit token. This is documented in the MediaWiki API documentation: 
https://www.mediawiki.org/wiki/API:Edit_-_Create%26Edit_pages

However for editing pages it's recommended that you use the functions in the 
Page object. Page.edit() will handle the token for you. It's not fully 
documented online yet, but most functions are documented in-code: 
https://code.google.com/p/python-wikitools/source/browse/trunk/wikitools/page.py
#479

Original comment by MrZmanwiki@gmail.com on 6 Mar 2012 at 4:41