-
Notifications
You must be signed in to change notification settings - Fork 15
Handler
YorickC edited this page Dec 24, 2014
·
17 revisions
![code_architecture] (https://raw.githubusercontent.com/mementoweb/timegate/master/doc/code_architecture.png)
A Handler is an API-specific piece of code that plugs into the TimeGate to match any kind of API. The handlers are kept as simple as possible. They require to have only the following:
- A handler must extend the
Handler
base-class, and it must be the only python class to do so. - Implement the
get_all_mementos(self, uri_r)
function. This function is called by the TimeGate to retrieve the history an original resourceuri_r
. The return value must be a list of pairs:[(uri_m1, date1), (uri_m2, date2), ...]
. Each pair(uri_m, date)
contains the URI of an archived version of Ruri_m
, and the date at which it was archiveddate
. All URI fields must be strings All Date fields must be strings formatted as the ISO, date format - If the API cannot return the entire history for a resource, the handler must implement the
get_memento(self, uri_r, date)
function. This function will be called by the TimeGate to retrieve the best Memento foruri_
at the datedate
. In this case, the return value will contain only one pair:(uri_m, date)
which is the best memento that the handler could provide taking into account the limits of the API.
Handlers examples are provided for several APIs:
Other scraping Handlers examples are provided for resources without any API.