def __init__(self, user, passwd, codec='iso-8859-1', api_request=dlcs_api_request, xml_parser=dlcs_parse_xml):
"""Initialize access to the API with ``user`` and ``passwd``.
``codec`` sets the encoding of the arguments.
The ``api_request`` and ``xml_parser`` parameters by default point to
functions within this package with standard implementations to
request and parse a resource. See ``dlcs_api_request()`` and
``dlcs_parse_xml()``. Note that ``api_request`` should return a
file-like instance with an HTTPMessage instance under ``info()``,
see ``urllib2.openurl`` for more info.
"""
assert user != ""
self.user = user
self.passwd = passwd
self.codec = codec
# Implement communication to server and parsing of respons messages:
assert callable(api_request)
self._api_request = api_request
assert callable(xml_parser)
self._parse_response = xml_parser
评论列表
文章目录