twitter/oauthtwitter.py
def _FetchUrl(self,
                    url,
                    post_data=None,
                    parameters=None,
                    no_cache=None):
        '''Fetch a URL, optionally caching for a specified time.
    
        Args:
          url: The URL to retrieve
          post_data: 
            A dict of (str, unicode) key/value pairs.  If set, POST will be used.
          parameters:
            A dict whose key/value pairs should encoded and added 
            to the query string. [OPTIONAL]
          no_cache: If true, overrides the cache on the current request
    
        Returns:
          A string containing the body of the response.
        '''
        # Build the extra parameters dict
        extra_params = {}
        if self._default_params:
          extra_params.update(self._default_params)
        if parameters:
          extra_params.update(parameters)
    
        # Add key/value parameters to the query string of the url
        #url = self._BuildUrl(url, extra_params=extra_params)
    
        if post_data:
            http_method = "POST"
            extra_params.update(post_data)
        else:
            http_method = "GET"
        
        req = self._makeOAuthRequest(url, parameters=extra_params, 
                                                    http_method=http_method)
        self._signRequest(req, self._signature_method)

        
        # Get a url opener that can handle Oauth basic auth
        opener = self._GetOpener()
        
        #encoded_post_data = self._EncodePostData(post_data)

        if post_data:
            encoded_post_data = req.to_postdata()
            url = req.get_normalized_http_url()
        else:
            url = req.to_url()
            encoded_post_data = ""
            
        no_cache=True
        # Open and return the URL immediately if we're not going to cache
        # OR we are posting data
        if encoded_post_data or no_cache:
          if encoded_post_data:
              url_data = opener.open(url, encoded_post_data).read()
          else:
              url_data = opener.open(url).read()
          opener.close()
        else:
          # Unique keys are a combination of the url and the username
          if self._username:
            key = self._username + ':' + url
          else:
            key = url
    
          # See if it has been cached before
          last_cached = self._cache.GetCachedTime(key)
    
          # If the cached version is outdated then fetch another and store it
          if not last_cached or time.time() >= last_cached + self._cache_timeout:
            url_data = opener.open(url).read()
            opener.close()
            self._cache.Set(key, url_data)
          else:
            url_data = self._cache.Get(key)
    
        # Always return the latest version
        return url_data
Fetch a URL, optionally caching for a specified time.
    
        Args:
          url: The URL to retrieve
          post_data: 
            A dict of (str, unicode) key/value pairs.  If set, POST will be used.
          parameters:
            A dict whose key/value pairs should encoded and added 
            to the query string. [OPTIONAL]
          no_cache: If true, overrides the cache on the current request
    
        Returns:
          A string containing the body of the response.
        
Fetch a URL, optionally caching for a specified time.
Fetch a URL optionally caching for a specified time .
def _FetchUrl(self,
                    url,
                    post_data=None,
                    parameters=None,
                    no_cache=None):
        extra_params = {}
        if self._default_params:
          extra_params.update(self._default_params)
        if parameters:
          extra_params.update(parameters)
        if post_data:
            http_method = "POST"
            extra_params.update(post_data)
        else:
            http_method = "GET"
        req = self._makeOAuthRequest(url, parameters=extra_params, 
                                                    http_method=http_method)
        self._signRequest(req, self._signature_method)
        opener = self._GetOpener()
        if post_data:
            encoded_post_data = req.to_postdata()
            url = req.get_normalized_http_url()
        else:
            url = req.to_url()
            encoded_post_data = ""
        no_cache=True
        if encoded_post_data or no_cache:
          if encoded_post_data:
              url_data = opener.open(url, encoded_post_data).read()
          else:
              url_data = opener.open(url).read()
          opener.close()
        else:
          if self._username:
            key = self._username + ':' + url
          else:
            key = url
          last_cached = self._cache.GetCachedTime(key)
          if not last_cached or time.time() >= last_cached + self._cache_timeout:
            url_data = opener.open(url).read()
            opener.close()
            self._cache.Set(key, url_data)
          else:
            url_data = self._cache.Get(key)
        return url_data
def _FetchUrl ( self , url , post_data = None , parameters = None , no_cache = None ) : extra_params = { } if self . _default_params : extra_params . update ( self . _default_params ) if parameters : extra_params . update ( parameters ) if post_data : http_method = "POST" extra_params . update ( post_data ) else : http_method = "GET" req = self . _makeOAuthRequest ( url , parameters = extra_params , http_method = http_method ) self . _signRequest ( req , self . _signature_method ) opener = self . _GetOpener ( ) if post_data : encoded_post_data = req . to_postdata ( ) url = req . get_normalized_http_url ( ) else : url = req . to_url ( ) encoded_post_data = "" no_cache = True if encoded_post_data or no_cache : if encoded_post_data : url_data = opener . open ( url , encoded_post_data ) . read ( ) else : url_data = opener . open ( url ) . read ( ) opener . close ( ) else : if self . _username : key = self . _username + ':' + url else : key = url last_cached = self . _cache . GetCachedTime ( key ) if not last_cached or time . time ( ) >= last_cached + self . _cache_timeout : url_data = opener . open ( url ) . read ( ) opener . close ( ) self . _cache . Set ( key , url_data ) else : url_data = self . _cache . Get ( key ) return url_data
Fetch a URL, optionally caching for a specified time.
Fetch a URL optionally caching for a specified time .
'''Fetch a URL, optionally caching for a specified time.
    
        Args:
          url: The URL to retrieve
          post_data: 
            A dict of (str, unicode) key/value pairs.  If set, POST will be used.
          parameters:
            A dict whose key/value pairs should encoded and added 
            to the query string. [OPTIONAL]
          no_cache: If true, overrides the cache on the current request
    
        Returns:
          A string containing the body of the response.
        ''' # Build the extra parameters dict # Add key/value parameters to the query string of the url #url = self._BuildUrl(url, extra_params=extra_params) # Get a url opener that can handle Oauth basic auth #encoded_post_data = self._EncodePostData(post_data) # Open and return the URL immediately if we're not going to cache # OR we are posting data # Unique keys are a combination of the url and the username # See if it has been cached before # If the cached version is outdated then fetch another and store it # Always return the latest version
A string containing the body of the response.
A string containing the body of the response .
self
url
The URL to retrieve
The URL to retrieve
post_data
A dict of (str, unicode) key/value pairs.  If set, POST will be used.
A dict of ( str unicode ) key / value pairs . If set POST will be used .
parameters
A dict whose key/value pairs should encoded and added
to the query string. [OPTIONAL]
A dict whose key / value pairs should encoded and added to the query string . [ OPTIONAL ]
no_cache
If true, overrides the cache on the current request
If true overrides the cache on the current request