| Home | Trees | Index | Help |
|
|---|
| Package pyxmpp :: Module cache :: Class CacheFetcher |
|
DiscoCacheFetcherBase
Base class for cache object fetchers -- classes responsible for
retrieving objects from network.
An instance of a fetcher class is created for each object requested and
not found in the cache, then `fetch` method is called to initialize
the asynchronous retrieval process. Fetcher object's `got_it` method
should be called on a successfull retrieval and `error` otherwise.
`timeout` will be called when the request timeouts.
:Ivariables:
- `cache`: cache object which created this fetcher.
- `address`: requested item address.
- `timeout_time`: timeout time.
- `active`: `True` as long as the fetcher is active and requestor
expects one of the handlers to be called.
:Types:
- `cache`: `Cache`
- `address`: any hashable
- `timeout_time`: `datetime`
- `active`: `bool`
| Method Summary | |
|---|---|
Initialize an `CacheFetcher` object. | |
Handle a retrieval error and call apriopriate handler. | |
Start the retrieval process. | |
Handle a successfull retrieval and call apriopriate handler. | |
Handle fetcher timeout and call apriopriate handler. | |
| Method Details |
|---|
__init__(self,
cache,
address,
item_freshness_period,
item_expiration_period,
item_purge_period,
object_handler,
error_handler,
timeout_handler,
timeout_period,
backup_state=None)
|
error(self, error_data)
Handle a retrieval error and call apriopriate handler.
Should be called when retrieval fails.
Do nothing when the fetcher is not active any more (after
one of handlers was already called).
:Parameters:
- `error_data`: additional information about the error (e.g. `StanzaError` instance).
:Types:
- `error_data`: fetcher dependant
|
fetch(self)Start the retrieval process. This method must be implemented in any fetcher class. |
got_it(self, value, state='new')
Handle a successfull retrieval and call apriopriate handler.
Should be called when retrieval succeeds.
Do nothing when the fetcher is not active any more (after
one of handlers was already called).
:Parameters:
- `value`: fetched object.
- `state`: initial state of the object.
:Types:
- `value`: any
- `state`: `str`
|
timeout(self)Handle fetcher timeout and call apriopriate handler. Is called by the cache object and should _not_ be called by fetcher or application. Do nothing when the fetcher is not active any more (after one of handlers was already called). |
| Home | Trees | Index | Help |
|
|---|
| Generated by Epydoc 2.1 on Wed May 31 22:37:02 2006 | http://epydoc.sf.net |