Package biblio :: Package webquery :: Module basewebquery :: Class BaseWebquery
[hide private]
[frames] | no frames]

Class BaseWebquery

source code

  object --+    
           |    
impl.ReprObj --+
               |
              BaseWebquery
Known Subclasses:

A base class for querying webservices.

This serves as a foundation for other web-query classes, centralising a small amount of functionality and providing a common interface.

Instance Methods [hide private]
 
__init__(self, root_url, timeout=5.0, limits=[])
Ctor, allowing the setting of the webservice, timeout and limits on use.
source code
 
request(self, sub_url)
Send a request to the webservice and return the response.
source code
 
_build_request_url(self, sub_url)
Assemble the full url for requesting data.
source code

Inherited from impl.ReprObj: __repr__, __str__, __unicode__

Inherited from object: __delattr__, __getattribute__, __hash__, __new__, __reduce__, __reduce_ex__, __setattr__

Class Variables [hide private]
  _repr_fields = ['root_url', 'timeout', 'limits']
Properties [hide private]

Inherited from object: __class__

Method Details [hide private]

__init__(self, root_url, timeout=5.0, limits=[])
(Constructor)

source code 
Ctor, allowing the setting of the webservice, timeout and limits on use.
Parameters:
  • root_url (string) - The url to be used as the basis for all requests to this service. It should be the common "stem" that does not vary for any request.
  • timeout (int or float) - How many seconds to wait for a response.
  • limits (iterable) - A list of QueryThrottles to impose upon the use of this webservice.
Overrides: object.__init__

request(self, sub_url)

source code 

Send a request to the webservice and return the response.

This is the low-level calls that checks any throttling, send the request and actually fetches the response data. For consistency, all service access should be placed through here.

Parameters:
  • sub_url (string) - This will be added to the root url set in the c'tor and used as the actual url that is requested.
Returns:
The data in the webservice response.

_build_request_url(self, sub_url)

source code 

Assemble the full url for requesting data.

This is an internal method, intended for over-riding or modifying the request construction in subclasses, for example where an access key must be included.

Parameters:
  • sub_url (string) - The later part of a request url that can change.
Returns:
The url to be used for the webservice request.