John Vandenberg has uploaded a new change for review.

  https://gerrit.wikimedia.org/r/160190

Change subject: merge two http.request calls in Request.submit
......................................................................

merge two http.request calls in Request.submit

Request.submit may submit using MIME or URL form.
Each approach invoked http.request, and then error handling
is performed in a uniform manner.

This patch moves the invocation out of each branch, so
changes to the http request parameters can be added in one
place rather than twice.

Change-Id: I47cbf80dac5b29f6d9548481815d47140aa0c575
---
M pywikibot/data/api.py
1 file changed, 8 insertions(+), 6 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/pywikibot/core 
refs/changes/90/160190/1

diff --git a/pywikibot/data/api.py b/pywikibot/data/api.py
index 0e846ae..bb086fc 100644
--- a/pywikibot/data/api.py
+++ b/pywikibot/data/api.py
@@ -431,13 +431,15 @@
                     eoh = body.find(marker)
                     body = body[eoh + len(marker):]
                     # retrieve the headers from the MIME object
-                    mimehead = dict(list(container.items()))
-                    rawdata = http.request(self.site, uri, method="POST",
-                                           headers=mimehead, body=body)
+                    headers = dict(list(container.items()))
                 else:
-                    rawdata = http.request(self.site, uri, method="POST",
-                                           headers={'Content-Type': 
'application/x-www-form-urlencoded'},
-                                           body=paramstring)
+                    headers = {'Content-Type': 
'application/x-www-form-urlencoded'}
+                    body = paramstring
+
+                rawdata = http.request(
+                    self.site, uri, method="POST",
+                    headers=headers, body=body)
+
 #                import traceback
 #                traceback.print_stack()
 #                print rawdata

-- 
To view, visit https://gerrit.wikimedia.org/r/160190
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: I47cbf80dac5b29f6d9548481815d47140aa0c575
Gerrit-PatchSet: 1
Gerrit-Project: pywikibot/core
Gerrit-Branch: master
Gerrit-Owner: John Vandenberg <[email protected]>

_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to