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

btongminh at svn.wikimedia.org btongminh at svn.wikimedia.org
Sun Jan 13 20:37:07 UTC 2008


Revision: 4877
Author:   btongminh
Date:     2008-01-13 20:37:07 +0000 (Sun, 13 Jan 2008)

Log Message:
-----------
wpEditToken is explicitly added as last value during urlEncoding. If a premature connection abort occurs while putting, the server will not have received an edit token and thus refuse saving the page.

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

Modified: trunk/pywikipedia/wikipedia.py
===================================================================
--- trunk/pywikipedia/wikipedia.py	2008-01-13 18:44:01 UTC (rev 4876)
+++ trunk/pywikipedia/wikipedia.py	2008-01-13 20:37:07 UTC (rev 4877)
@@ -3816,6 +3816,7 @@
         else:
             iterator = iter(query)
         l = []
+        wpEditToken = None
         for key, value in iterator:
             if isinstance(key, unicode):
                 key = key.encode('utf-8')
@@ -3823,7 +3824,16 @@
                 value = value.encode('utf-8')
             key = urllib.quote(key)
             value = urllib.quote(value)
+            if key == 'wpEditToken':
+                wpEditToken = value
+                continue
             l.append(key + '=' + value)
+            
+        # wpEditToken is explicitly added as last value.
+        # If a premature connection abort occurs while putting, the server will
+        # not have received an edit token and thus refuse saving the page
+        if wpEditToken != None:
+            l.append('wpEditToken=' + wpEditToken)
         return '&'.join(l)
 
     def postForm(self, address, predata, sysop=False, useCookie=True):





More information about the Pywikipedia-l mailing list