Revision: 7219
Author: russblau
Date: 2009-09-07 18:12:56 +0000 (Mon, 07 Sep 2009)
Log Message:
-----------
Edit conflict detection.
Modified Paths:
--------------
branches/rewrite/pywikibot/site.py
Modified: branches/rewrite/pywikibot/site.py
===================================================================
--- branches/rewrite/pywikibot/site.py 2009-09-07 09:12:09 UTC (rev 7218)
+++ branches/rewrite/pywikibot/site.py 2009-09-07 18:12:56 UTC (rev 7219)
@@ -2187,16 +2187,23 @@
except NoPage:
lastrev = None
if not recreate:
- raise
+ raise
token = self.token(page, "edit")
+ # getting token also updates the 'lastrevid' value, which allows us to
+ # detect if page has been changed since last time text was retrieved.
+
+ # note that the server can still return an 'editconflict' error
+ # if the page is updated after the token is retrieved but
+ # before the page is saved.
self.lock_page(page)
if lastrev is not None and page.latestRevision() != lastrev:
- raise Error("editpage: Edit conflict detected; saving aborted.")
+ raise EditConflict(
+ "editpage: Edit conflict detected; saving aborted.")
req = api.Request(site=self, action="edit",
title=page.title(withSection=False),
text=text, token=token, summary=summary)
-## if lastrev is not None:
-## req["basetimestamp"] = page._revisions[lastrev].timestamp
+ if lastrev is not None:
+ req["basetimestamp"] = page._revisions[lastrev].timestamp
if minor:
req['minor'] = ""
elif notminor:
Revision: 7216
Author: alexsh
Date: 2009-09-06 15:45:27 +0000 (Sun, 06 Sep 2009)
Log Message:
-----------
Page().put(): add check permission `editusercssjs` if use_api enable in edit user css and js.
Modified Paths:
--------------
trunk/pywikipedia/wikipedia.py
Modified: trunk/pywikipedia/wikipedia.py
===================================================================
--- trunk/pywikipedia/wikipedia.py 2009-09-06 15:42:59 UTC (rev 7215)
+++ trunk/pywikipedia/wikipedia.py 2009-09-06 15:45:27 UTC (rev 7216)
@@ -1402,6 +1402,9 @@
if not force:
if not self.botMayEdit(username):
raise LockedPage(u'Not allowed to edit %s because of a restricting template' % self.aslink())
+ elif config.use_api and self.namespace() in [2,3] and ( '.css' in self.title() or '.js' in self.title()):
+ # API enable: if title is .css or .js in ns2,3 , it need permission `editusercssjs`
+ sysop = self._getActionUser(action = 'editusercssjs', restriction = self.editRestriction, sysop=True)
# If there is an unchecked edit restriction, we need to load the page
if self._editrestriction:
Revision: 7214
Author: alexsh
Date: 2009-09-06 14:16:31 +0000 (Sun, 06 Sep 2009)
Log Message:
-----------
terminal_interface.UI().askForCaptcha(): fix url show and handle web browser open failure.
Modified Paths:
--------------
trunk/pywikipedia/userinterfaces/terminal_interface.py
Modified: trunk/pywikipedia/userinterfaces/terminal_interface.py
===================================================================
--- trunk/pywikipedia/userinterfaces/terminal_interface.py 2009-09-05 12:45:15 UTC (rev 7213)
+++ trunk/pywikipedia/userinterfaces/terminal_interface.py 2009-09-06 14:16:31 UTC (rev 7214)
@@ -287,8 +287,11 @@
try:
import webbrowser
wikipedia.output(u'Opening CAPTCHA in your web browser...')
- webbrowser.open(url)
- return wikipedia.input(u'What is the solution of the CAPTCHA that is shown in your web browser?')
+ if webbrowser.open(url):
+ return wikipedia.input(u'What is the solution of the CAPTCHA that is shown in your web browser?')
+ else:
+ raise
except:
wikipedia.output(u'Error in opening web browser: %s' % sys.exc_info()[0])
- return wikipedia.input(u'What is the solution of the CAPTCHA at %s ?' % url)
+ wikipedia.output(u'Please copy this url to your web browser and open it:\n %s' % url)
+ return wikipedia.input(u'What is the solution of the CAPTCHA at this url ?')