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

Class ConfirmationEngine

source code


The confirmation engine is what does the work of sending a confirmation, and verifying that it was confirmed properly. In order to use it you have to construct the ConfirmationEngine (usually in config/settings.py) and you write your confirmation message templates for sending.

The primary methods you use are ConfirmationEngine.send and ConfirmationEngine.verify.

Instance Methods [hide private]
 
__init__(self, pending_queue, storage)
The pending_queue should be a string with the path to the lamson.queue.Queue that will store pending messages.
source code
 
get_pending(self, pending_id)
Returns the pending message for the given ID.
source code
 
push_pending(self, message)
Puts a pending message into the pending queue.
source code
 
delete_pending(self, pending_id)
Removes the pending message from the pending queue.
source code
 
cancel(self, target, from_address, expect_secret)
Used to cancel a pending confirmation.
source code
 
make_random_secret(self)
Generates a random uuid as the secret, in hex form.
source code
 
register(self, target, message)
Don't call this directly unless you know what you are doing.
source code
 
verify(self, target, from_address, expect_secret)
Given a target (i.e.
source code
 
send(self, relay, target, message, template, vars)
This is the method you should use to send out confirmation messages.
source code
 
clear(self)
Used in testing to make sure there's nothing in the pending queue or storage.
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, pending_queue, storage)
(Constructor)

source code 

The pending_queue should be a string with the path to the lamson.queue.Queue that will store pending messages. These messages are the originals the user sent when they tried to confirm.

Storage should be something that is like ConfirmationStorage so that this can store things for later verification.

Overrides: object.__init__

get_pending(self, pending_id)

source code 

Returns the pending message for the given ID.

push_pending(self, message)

source code 

Puts a pending message into the pending queue.

delete_pending(self, pending_id)

source code 

Removes the pending message from the pending queue.

cancel(self, target, from_address, expect_secret)

source code 

Used to cancel a pending confirmation.

make_random_secret(self)

source code 

Generates a random uuid as the secret, in hex form.

register(self, target, message)

source code 

Don't call this directly unless you know what you are doing. It does the job of registering the original message and the expected confirmation into the storage.

verify(self, target, from_address, expect_secret)

source code 

Given a target (i.e. "subscribe", "post", etc), a from_address of someone trying to confirm, and the secret they should use, this will try to verify their confirmation. If the verify works then you'll get the original message back to do what you want with.

If the verification fails then you are given None.

The message is *not* deleted from the pending queue. You can do that yourself with delete_pending.

send(self, relay, target, message, template, vars)

source code 

This is the method you should use to send out confirmation messages. You give it the relay, a target (i.e. "subscribe"), the message they sent requesting the confirm, your confirmation template, and any vars that template needs.

The result of calling this is that the template message gets sent through the relay, the original message is stored in the pending queue, and data is put into the storage for later calls to verify.

clear(self)

source code 

Used in testing to make sure there's nothing in the pending queue or storage.