request_database submodule¶
This module is used to keep incomming and outgoing structures and also for serialization/deserialization to/from XML.
- class aleph_link_export.request_database.RequestDatabase(log_fn='/home/aleph_export/link_export.log', db_fn='/home/aleph_export/request_datase.shelve', db_key='request_database', logging=True, req_fn='/home/aleph_export/edep2aleph/requests.xml', resp_fn='/home/aleph_export/aleph2edep/responses.xml', xsd_url='http://edeposit-aplikace.nkp.cz/link_export_notification.xsd')¶
Bases: aleph_link_export.shelvedb.ShelveDatabase
Keep the track of requests and resposes and their serialization and deserialization from/to XMl.
- req_fn = None¶
Path to the request XML.
- resp_fn = None¶
Path to the response XML
- add_request(request)¶
Add new request object to database.
Parameters: request (obj) – Object with defined session_id property and to_dict_xml() method.
- get_responses()¶
Process response queue, remove finished requests from request queue, return list of response objects.
Returns: List of LinkUpdateResponse objects. Return type: list
- to_xml()¶
Convert _req_queue to XML as defined in request XSD.
Returns: XML. Return type: unicode
- save()¶
Read the response XML, process it, save the database and request XML.
- static load(fn='/home/aleph_export/request_datase.shelve', db_key='request_database', creator=<function <lambda> at 0x7fecf3a9d8c0>)¶
Load the database from the shelve fn.
Parameters: - fn (str) – Path to the database file. Default DATABASE_FN.
- db_key (str) – What database key to use. Default DATABASE_KEY.
- creator (fn reference) – Reference to the function, which will create new RequestDatabase if the old is not found. Default lambda, which expects fn parameter lambda fn: ...
Returns: RequestDatabase instance from the fn or newly created.
Return type: obj