Module isbn :: Class SRU
[hide private]
[frames] | no frames]

Class SRU

source code

object --+
         |
        SRU
Known Subclasses:

Base class for all classes that implement retrieval of book information via a webservice.

Instance Methods [hide private]
 
__init__(self, url, contenthandlerfactory, name)
Returns: an SRU instance.
source code
 
fetch(self, isbn)
Retrieve information about a book based on isbn number.
source code
 
retrieve(self, f)
Parse results in xml from an open file descriptor.
source code
 
getName(self) source code

Inherited from object: __delattr__, __format__, __getattribute__, __hash__, __new__, __reduce__, __reduce_ex__, __repr__, __setattr__, __sizeof__, __str__, __subclasshook__

Properties [hide private]

Inherited from object: __class__

Method Details [hide private]

__init__(self, url, contenthandlerfactory, name)
(Constructor)

source code 

x.__init__(...) initializes x; see x.__class__.__doc__ for signature

Parameters:
  • url (string.) - an url that will be used to retrieve information. Should contain a single '%s' placeholder to fot an isbn number.
  • contenthandlerfactory (ContentHandler.) - a reference to a ContentHandler derived class.
  • name (string.) - the visible name for this class, stored in the result on success.
Returns:
an SRU instance.
Overrides: object.__init__

fetch(self, isbn)

source code 

Retrieve information about a book based on isbn number.

Parameters:
  • isbn (string.) - an isbn-10 or isbn-13 number.
Returns:
nothing, result is stored in result.
Raises:
  • SRUError - if no result could be retrieved.

retrieve(self, f)

source code 

Parse results in xml from an open file descriptor.

Parameters:
  • f - a file descriptor supporting a read() method as e.g. returned from urlopen().
Returns:
nothing, result is stored in result.
Raises:
  • SRUError - if no result could be retrieved.

    fetch and retrieve are separated to facilitate derived classes that need to do something to the url before sending it and retrieving the results. They still can reuse the actual handling of the returned xml. See Amazon class for an example.