1.11.12.2 Store Objects

The store object is obtained from the store() method of the manager object. It is used to manipulate the session store of the application specified in the store() method.

class Store

store objects have the following attribute:

app
This is the name of the application whose store we are manipulating. app can be set to another application's name in order to manipulate a different session store. Application names are strings made up of the characters a-z, A-Z, 0-9 and -_. and are between 1 and 255 characters in length.

store objects have the following methods:

set( key, value)
Set the value of key to the value value in the session store. value can be any Python object capable of being pickled. See Python's pickle module for more information.

get( key)
Get the value of key from the session store.

delete( key)
Remove key and its associated value from the session store.

empty( )
Empty this application's session store of all information removing all keys and values but leaving the session itself and other application's stores intact.

has_key( key)
Returns True if key exists on the session store otherwise False.

keys( )
Returns a sequence of store keys. The order of the keys is not defined. Keys obtained from this method cannot be set directly. Instead the set() method should be used.

items( )
Returns a tuple of (key, value) pairs for each key in the store. The order of the values is not defined. Values and keys obtained from this method cannot be set directly. Instead the set() method should be used.

values( )
Returns a sequence of store values. The order of the values is not defined. Values obtained from this method cannot be set directly. Instead the set() method should be used.

store objects also implement the following methods: __getitem__(key), __setitem__(key, value) and __delitem__(key) which map directly to the get(key), set(key) and delete(key) methods respectively and allow the store object to be treated similarly to a dictionary as demonstrated earlier in the documentation.