Sybren Stüvel avatar Sybren Stüvel committed b9dfe93

Moved urllib2-specific code to _http_post method

Comments (0)

Files changed (1)

flickrapi/__init__.py

         if self.cache and self.cache.get(post_data):
             return self.cache.get(post_data)
 
-        url = "http://" + self.flickr_host + self.flickr_rest_form
-        flicksocket = urllib2.urlopen(url, post_data)
-        reply = flicksocket.read()
-        flicksocket.close()
+        reply = self._http_post(post_data)
 
         # Store in cache, if we have one
         if self.cache is not None:
             self.cache.set(post_data, reply)
 
         return reply
+
+    def _http_post(self, post_data):
+        '''Performs a HTTP POST call to the Flickr REST URL.'''
+
+        url = "http://" + self.flickr_host + self.flickr_rest_form
+        flicksocket = urllib2.urlopen(url, post_data)
+        reply = flicksocket.read()
+        flicksocket.close()
+
+        return reply
+
     
     def _wrap_in_parser(self, wrapped_method, parse_format, *args, **kwargs):
         '''Wraps a method call in a parser.
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.