[Pywikipedia-l] SVN: [5370] trunk/pywikipedia/wikipedia.py

filnik at svn.wikimedia.org filnik at svn.wikimedia.org
Wed May 14 14:10:43 UTC 2008


Revision: 5370
Author:   filnik
Date:     2008-05-14 14:10:43 +0000 (Wed, 14 May 2008)

Log Message:
-----------
Don't raise an error if the page was delated but simply take the lost 2 parameters and add them in the list of what to commit to the server. If anyone has a better solution, just commit it ;-) 

Modified Paths:
--------------
    trunk/pywikipedia/wikipedia.py

Modified: trunk/pywikipedia/wikipedia.py
===================================================================
--- trunk/pywikipedia/wikipedia.py	2008-05-14 13:07:37 UTC (rev 5369)
+++ trunk/pywikipedia/wikipedia.py	2008-05-14 14:10:43 UTC (rev 5370)
@@ -1079,12 +1079,12 @@
                 if self.site().has_mediawiki_message("Istemplate") \
                         and self._istemplatemessage in textafter:
                     istemplate = True
-
             if (withTemplateInclusion or onlyTemplateInclusion or not istemplate
                     ) and (not redirectsOnly or isredirect
                     ) and (not onlyTemplateInclusion or istemplate
                     ):
                 yield p
+                continue
 
             if isredirect and follow_redirects:
                 sublist = link.find("ul")
@@ -1301,15 +1301,17 @@
             predata['masteredit'] = '1'
 
         retry_delay = 1
+        already_advise = False
         while True:
             # Check whether we are not too quickly after the previous
             # putPage, and wait a bit until the interval is acceptable
             put_throttle()
             # Which web-site host are we submitting to?
-            if newPage:
-                output(u'Creating page %s' % self.aslink(forceInterwiki=True))
-            else:
-                output(u'Changing page %s' % self.aslink(forceInterwiki=True))
+            if not already_advise:
+                if newPage:
+                    output(u'Creating page %s' % self.aslink(forceInterwiki=True))
+                else:
+                    output(u'Changing page %s' % self.aslink(forceInterwiki=True))
             # Submit the prepared information
             if self.site().hostname() in config.authenticate.keys():
                 predata["Content-type"] = "application/x-www-form-urlencoded"
@@ -1376,7 +1378,12 @@
             if '<label for=\'wpRecreate\'' in data:
                 # Make sure your system clock is correct if this error occurs
                 # without any reason!
-                raise EditConflict(u'Someone deleted the page.')
+                # raise EditConflict(u'Someone deleted the page.')
+                # No raise, simply define these variables and retry:
+                predata['wpEdittime'] = self._editTime
+                predata['wpStarttime'] = self._startTime
+                already_advise = True # Note print "Creating/Changing" again without reason..
+                continue
             if self.site().has_mediawiki_message("viewsource")\
                     and self.site().mediawiki_message('viewsource') in data:
                 # The page is locked. This should have already been





More information about the Pywikipedia-l mailing list