http://www.mediawiki.org/wiki/Special:Code/pywikipedia/9743
Revision: 9743 Author: xqt Date: 2011-11-11 00:35:04 +0000 (Fri, 11 Nov 2011) Log Message: ----------- mw 1.18 changes: watch token is needed for watch action (bug reported by Betacommand)
Modified Paths: -------------- trunk/pywikipedia/wikipedia.py
Modified: trunk/pywikipedia/wikipedia.py =================================================================== --- trunk/pywikipedia/wikipedia.py 2011-11-11 00:29:54 UTC (rev 9742) +++ trunk/pywikipedia/wikipedia.py 2011-11-11 00:35:04 UTC (rev 9743) @@ -2929,6 +2929,19 @@ 'action': 'watch', 'title': self.title() } + # watchtoken is needed for mw 1.18 + # TODO: Find a better implementation for other actions too + # who needs a token + if self.site().versionnumber() >= 18: + api = { + 'action': 'query', + 'prop': 'info', + 'titles' : self.title(), + 'intoken' : 'watch', + } + data = query.GetData(api, self.site()) + key = data['query']['pages'].keys()[0] + params['token'] = data['query']['pages'][key]['watchtoken'] if unwatch: params['unwatch'] = ''
@@ -2947,8 +2960,9 @@ def unwatch(self): self.watch(unwatch=True)
- def move(self, newtitle, reason=None, movetalkpage=True, movesubpages=False, sysop=False, - throttle=True, deleteAndMove=False, safe=True, fixredirects=True, leaveRedirect=True): + def move(self, newtitle, reason=None, movetalkpage=True, movesubpages=False, + sysop=False, throttle=True, deleteAndMove=False, safe=True, + fixredirects=True, leaveRedirect=True): """Move this page to new title.
* fixredirects has no effect in MW < 1.13
pywikipedia-svn@lists.wikimedia.org