Revision: 7081
Author:   alexsh
Date:     2009-07-19 12:42:54 +0000 (Sun, 19 Jul 2009)

Log Message:
-----------
query.GetData():Add response parameter

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

Modified: trunk/pywikipedia/query.py
===================================================================
--- trunk/pywikipedia/query.py  2009-07-19 12:40:06 UTC (rev 7080)
+++ trunk/pywikipedia/query.py  2009-07-19 12:42:54 UTC (rev 7081)
@@ -28,7 +28,7 @@
 
 import wikipedia, simplejson, urllib, time
 
-def GetData(params, site = None, verbose = False, useAPI = False, retryCount = 
5, encodeTitle = True):
+def GetData(params, site = None, verbose = False, useAPI = False, retryCount = 
5, encodeTitle = True, back_response = False):
     """Get data from the query api, and convert it into a data object
     """
     if site is None:
@@ -84,11 +84,17 @@
             if params['action'] in postAC:
                 res, jsontext = site.postData(path, 
urllib.urlencode(params.items()), cookies=site.cookies())
             else:
-                jsontext = site.getUrl( path, retry=True, data=data )
+                if back_response:
+                    res, jsontext = site.getUrl( path, retry=True, data=data, 
back_response=True)
+                else:
+                    jsontext = site.getUrl( path, retry=True, data=data)
 
             # This will also work, but all unicode strings will need to be 
converted from \u notation
             # decodedObj = eval( jsontext )
-            return simplejson.loads( jsontext )
+            if back_response:
+                return res, simplejson.loads( jsontext )
+            else:
+                return simplejson.loads( jsontext )
 
         except ValueError, error:
             retryCount -= 1



_______________________________________________
Pywikipedia-svn mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/pywikipedia-svn

Reply via email to