Package wtf :: Package app :: Package services :: Module session :: Class StorageAdapter
[hide private]
[frames] | no frames]

Class StorageAdapter

source code

object --+
         |
        StorageAdapter

Storage adapter

This class acts a glue code between the session object, middleware and storage implementations. It provides all interfaces needed both by the public session object and the middleware. The lazyness of session initialization and store back are also implemented here.

Instance Methods [hide private]
 
__init__(self, factory, request=None)
Initialization
source code
any
__getattr__(self, name)
Resolve unknown attributes
source code
 
new(self)
Create a fresh session
source code
any
get(self, name)
Retrieve a attribute value
source code
bool
contains(self, name)
Determine whether an attribute exists
source code
 
set(self, name, value)
Set or replace an attribute
source code
 
delete(self, name)
Delete an attribute
source code
 
store_back(self)
Store back the session
source code
 
wipe(self)
Wipe session in storage
source code
str
cookie(self)
Ask the storage for a cookie if necessary
source code

Inherited from object: __delattr__, __format__, __getattribute__, __hash__, __new__, __reduce__, __reduce_ex__, __repr__, __setattr__, __sizeof__, __str__, __subclasshook__

Class Variables [hide private]
  _stored = False
Instance Variables [hide private]
bool _dirty = False
Is the session dirty (need store back)?
tuple _factory
Tuple of storage factory and request object.
StorageInterface _storage
Lazily initialized storage instance (on first access)
Properties [hide private]

Inherited from object: __class__

Method Details [hide private]

__init__(self, factory, request=None)
(Constructor)

source code 
Initialization
Parameters:
Overrides: object.__init__

__getattr__(self, name)
(Qualification operator)

source code 

Resolve unknown attributes

Effectively resolve the _storage attribute lazily. The attribute will be cached in the instance, so this method is called only once (for _storage).

Parameters:
  • name (str) - The attribute name to resolve
Returns: any
The resolved attribute value
Raises:
  • AttributeError - Attribute not found

get(self, name)

source code 
Retrieve a attribute value
Parameters:
  • name (str) - The attribute name to look up
Returns: any
attribute value
Raises:
  • KeyError - Attribute not found

contains(self, name)

source code 
Determine whether an attribute exists
Parameters:
  • name (str) - The name to check
Returns: bool
Does the attribute exist?

set(self, name, value)

source code 
Set or replace an attribute
Parameters:
  • name (str) - Attribute name
  • value (any) - Attribute value (must be pickleable)

delete(self, name)

source code 
Delete an attribute
Parameters:
  • name (str) - The name of the attribute to delete

store_back(self)

source code 
Store back the session

Note: The session is only stored back, if it's marked dirty.

cookie(self)

source code 
Ask the storage for a cookie if necessary
Returns: str
The cookie string or None

Instance Variable Details [hide private]

_factory

Tuple of storage factory and request object. When the storage is initialized, this attribute becomes None
Type:
tuple