Package lamson :: Module confirm :: Class ConfirmationStorage
[hide private]
[frames] | no frames]

Class ConfirmationStorage

source code


This is the basic confirmation storage. For simple testing purposes you can just use the default hash db parameter. If you do a deployment you can probably get away with a shelf hash instead.

You can write your own version of this and use it. The confirmation engine only cares that it gets something that supports all of these methods.

Instance Methods [hide private]
 
__init__(self, db={})
Change the db parameter to a shelf to get persistent storage.
source code
 
clear(self)
Used primarily in testing, this clears out all pending confirmations.
source code
 
key(self, target, from_address)
Used internally to construct a string key, if you write your own you don't need this.
source code
 
get(self, target, from_address)
Given a target and a from address, this returns a tuple of (expected_secret, pending_message_id).
source code
 
delete(self, target, from_address)
Removes a target+from_address from the storage.
source code
 
store(self, target, from_address, expected_secret, pending_message_id)
Given a target, from_address it will store the expected_secret and pending_message_id of later verification.
source code

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, db={})
(Constructor)

source code 

Change the db parameter to a shelf to get persistent storage.

Overrides: object.__init__

clear(self)

source code 

Used primarily in testing, this clears out all pending confirmations.

key(self, target, from_address)

source code 

Used internally to construct a string key, if you write your own you don't need this.

NOTE: To support proper equality and shelve storage, this encodes the key into ASCII. Make a different subclass if you need unicode and your storage supports it.

get(self, target, from_address)

source code 

Given a target and a from address, this returns a tuple of (expected_secret, pending_message_id). If it doesn't find that target+from_address, then it should return a (None, None) tuple.

delete(self, target, from_address)

source code 

Removes a target+from_address from the storage.

store(self, target, from_address, expected_secret, pending_message_id)

source code 

Given a target, from_address it will store the expected_secret and pending_message_id of later verification. The target should be a string indicating what is being confirmed. Like "subscribe", "post", etc.

When implementing your own you should *never* allow more than one target+from_address combination.