Package openid :: Package store :: Module sqlstore :: Class SQLStore
[frames] | no frames]

Class SQLStore

source code

           object --+    
                    |    
interface.OpenIDStore --+
                        |
                       SQLStore
Known Subclasses:

This is the parent class for the SQL stores, which contains the logic common to all of the SQL stores.

The table names used are determined by the class variables associations_table and nonces_table. To change the name of the tables used, pass new table names into the constructor.

To create the tables with the proper schema, see the createTables method.

This class shouldn't be used directly. Use one of its subclasses instead, as those contain the code necessary to use a specific database.

All methods other than __init__ and createTables should be considered implementation details.

Instance Methods
 
__init__(self, conn, associations_table=None, nonces_table=None)
This creates a new SQLStore instance.
source code
 
createTables(self, *args, **kwargs)
This method creates the database tables necessary for this store to work.
source code
 
blobDecode(self, blob)
Convert a blob as returned by the SQL engine into a str object.
source code
 
blobEncode(self, s)
Convert a str object into the necessary object for storing in the database as a blob.
source code
 
__getattr__(self, attr) source code
 
txn_createTables(self)
This method creates the database tables necessary for this store to work.
source code
 
txn_storeAssociation(self, server_url, association)
Set the association for the server URL.
source code
NoneType
storeAssociation(self, *args, **kwargs)
Set the association for the server URL.
source code
 
txn_getAssociation(self, server_url, handle=None)
Get the most recent association that has been set for this server URL and handle.
source code
Association or NoneType
getAssociation(self, *args, **kwargs)
Get the most recent association that has been set for this server URL and handle.
source code
 
txn_removeAssociation(self, server_url, handle)
Remove the association for the given server URL and handle, returning whether the association existed at all.
source code
bool or int
removeAssociation(self, *args, **kwargs)
Remove the association for the given server URL and handle, returning whether the association existed at all.
source code
 
txn_useNonce(self, server_url, timestamp, salt)
Return whether this nonce is present, and if it is, then remove it from the set.
source code
bool
useNonce(self, *args, **kwargs)
Return whether this nonce is present, and if it is, then remove it from the set.
source code
 
txn_cleanupNonces(self) source code
int
cleanupNonces(self, *args, **kwargs)
Remove expired nonces from the store.
source code
 
txn_cleanupAssociations(self) source code
int
cleanupAssociations(self, *args, **kwargs)
Remove expired associations from the store.
source code

Inherited from interface.OpenIDStore: cleanup

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

Class Variables
  associations_table = 'oid_associations'
This is the default name of the table to keep associations in
  nonces_table = 'oid_nonces'
This is the default name of the table to keep nonces in.
Properties

Inherited from object: __class__

Method Details

__init__(self, conn, associations_table=None, nonces_table=None)
(Constructor)

source code 

This creates a new SQLStore instance. It requires an established database connection be given to it, and it allows overriding the default table names.

Parameters:
  • conn (A python database API compatible connection object.) - This must be an established connection to a database of the correct type for the SQLStore subclass you're using.
  • associations_table (str) - This is an optional parameter to specify the name of the table used for storing associations. The default value is specified in SQLStore.associations_table.
  • nonces_table (str) - This is an optional parameter to specify the name of the table used for storing nonces. The default value is specified in SQLStore.nonces_table.
Overrides: object.__init__

createTables(self, *args, **kwargs)

source code 

This method creates the database tables necessary for this store to work. It should not be called if the tables already exist.

blobDecode(self, blob)

source code 

Convert a blob as returned by the SQL engine into a str object.

str -> str

txn_createTables(self)

source code 

This method creates the database tables necessary for this store to work. It should not be called if the tables already exist.

txn_storeAssociation(self, server_url, association)

source code 

Set the association for the server URL.

Association -> NoneType

storeAssociation(self, *args, **kwargs)

source code 

Set the association for the server URL.

Association -> NoneType

Parameters:
  • server_url - The URL of the identity server that this association is with. Because of the way the server portion of the library uses this interface, don't assume there are any limitations on the character set of the input string. In particular, expect to see unescaped non-url-safe characters in the server_url field.
  • association - The Association to store.
Returns: NoneType
None
Overrides: interface.OpenIDStore.storeAssociation

txn_getAssociation(self, server_url, handle=None)

source code 

Get the most recent association that has been set for this server URL and handle.

str -> NoneType or Association

getAssociation(self, *args, **kwargs)

source code 

Get the most recent association that has been set for this server URL and handle.

str -> NoneType or Association

Parameters:
  • server_url - The URL of the identity server to get the association for. Because of the way the server portion of the library uses this interface, don't assume there are any limitations on the character set of the input string. In particular, expect to see unescaped non-url-safe characters in the server_url field.
  • handle - This optional parameter is the handle of the specific association to get. If no specific handle is provided, any valid association matching the server URL is returned.
Returns: Association or NoneType
The Association for the given identity server.
Overrides: interface.OpenIDStore.getAssociation

txn_removeAssociation(self, server_url, handle)

source code 

Remove the association for the given server URL and handle, returning whether the association existed at all.

(str, str) -> bool

removeAssociation(self, *args, **kwargs)

source code 

Remove the association for the given server URL and handle, returning whether the association existed at all.

(str, str) -> bool

Parameters:
  • server_url - The URL of the identity server the association to remove belongs to. Because of the way the server portion of the library uses this interface, don't assume there are any limitations on the character set of the input string. In particular, expect to see unescaped non-url-safe characters in the server_url field.
  • handle - This is the handle of the association to remove. If there isn't an association found that matches both the given URL and handle, then there was no matching handle found.
Returns: bool or int
Returns whether or not the given association existed.
Overrides: interface.OpenIDStore.removeAssociation

txn_useNonce(self, server_url, timestamp, salt)

source code 

Return whether this nonce is present, and if it is, then remove it from the set.

str -> bool

useNonce(self, *args, **kwargs)

source code 

Return whether this nonce is present, and if it is, then remove it from the set.

str -> bool

Parameters:
  • server_url - The URL of the server from which the nonce originated.
  • timestamp - The time that the nonce was created (to the nearest second), in seconds since January 1 1970 UTC.
  • salt - A random string that makes two nonces from the same server issued during the same second unique.
Returns: bool
Whether or not the nonce was valid.
Overrides: interface.OpenIDStore.useNonce

cleanupNonces(self, *args, **kwargs)

source code 

Remove expired nonces from the store.

Discards any nonce from storage that is old enough that its timestamp would not pass useNonce.

This method is not called in the normal operation of the library. It provides a way for store admins to keep their storage from filling up with expired data.

Returns: int
the number of nonces expired.
Overrides: interface.OpenIDStore.cleanupNonces
(inherited documentation)

cleanupAssociations(self, *args, **kwargs)

source code 

Remove expired associations from the store.

This method is not called in the normal operation of the library. It provides a way for store admins to keep their storage from filling up with expired data.

Returns: int
the number of associations expired.
Overrides: interface.OpenIDStore.cleanupAssociations
(inherited documentation)