Package lamson :: Module routing :: Class ShelveStorage
[hide private]
[frames] | no frames]

Class ShelveStorage

source code


Uses Python's shelve to store the state of the Routers to disk rather than in memory like with MemoryStorage. This will get you going on a small install if you need to persist your states (most likely), but if you have a database, you'll need to write your own StateStorage that uses your ORM or database to store. Consider this an example.

NOTE: Because of shelve limitations you can only use ASCII encoded keys.

Instance Methods [hide private]
 
__init__(self, database_path)
Database path depends on the backing library use by Python's shelve.
source code
 
get(self, key, sender)
This will lock the internal thread lock, and then retrieve from the shelf whatever key you request.
source code
 
set(self, key, sender, state)
Acquires the self.lock and then sets the requested state in the shelf.
source code
 
clear(self)
Primarily used in the debugging/unit testing process to make sure the states are clear.
source code

Inherited from MemoryStorage: key

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, database_path)
(Constructor)

source code 

Database path depends on the backing library use by Python's shelve.

Overrides: object.__init__

get(self, key, sender)

source code 

This will lock the internal thread lock, and then retrieve from the shelf whatever key you request. If the key is not found then it will set (atomically) to ROUTE_FIRST_STATE.

Overrides: StateStorage.get

set(self, key, sender, state)

source code 

Acquires the self.lock and then sets the requested state in the shelf.

Overrides: StateStorage.set

clear(self)

source code 

Primarily used in the debugging/unit testing process to make sure the states are clear. In production this could be a bad thing.

Overrides: StateStorage.clear