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

Type SQLStore

 object --+    
          |    
OpenIDStore --+
              |
             SQLStore

Known Subclasses:
MySQLStore, PostgreSQLStore, SQLiteStore

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.
Method Summary
  __init__(self, conn, associations_table, nonces_table)
This creates a new SQLStore instance.
  createTables(self, *args, **kwargs)
This method creates the database tables necessary for this store to work.
  __getattr__(self, attr)
  blobDecode(self, blob)
Convert a blob as returned by the SQL engine into a str object.
  blobEncode(self, s)
Convert a str object into the necessary object for storing in the database as a blob.
int cleanupAssociations(self)
Remove expired associations from the store.
int cleanupNonces(self)
Remove expired nonces from the store.
  getAssociation(self, *args, **kwargs)
Get the most recent association that has been set for this server URL and handle.
  removeAssociation(self, *args, **kwargs)
Remove the association for the given server URL and handle, returning whether the association existed at all.
  storeAssociation(self, *args, **kwargs)
Set the association for the server URL.
  txn_cleanupAssociations(self)
  txn_cleanupNonces(self)
  txn_createTables(self)
This method creates the database tables necessary for this store to work.
  txn_getAssociation(self, server_url, handle)
Get the most recent association that has been set for this server URL and handle.
  txn_removeAssociation(self, server_url, handle)
Remove the association for the given server URL and handle, returning whether the association existed at all.
  txn_storeAssociation(self, server_url, association)
Set the association for the server URL.
  txn_useNonce(self, server_url, timestamp, salt)
Return whether this nonce is present, and if it is, then remove it from the set.
  useNonce(self, *args, **kwargs)
Return whether this nonce is present, and if it is, then remove it from the set.
Inherited from OpenIDStore: cleanup
Inherited from object: __delattr__, __getattribute__, __hash__, __new__, __reduce__, __reduce_ex__, __repr__, __setattr__, __str__

Class Variable Summary
str associations_table: This is the default name of the table to keep associations in
str nonces_table: This is the default name of the table to keep nonces in.

Method Details

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

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 - This must be an established connection to a database of the correct type for the SQLStore subclass you're using.
           (type=A python database API compatible connection object.)
associations_table - 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.
           (type=str)
nonces_table - 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.
           (type=str)
Overrides:
__builtin__.object.__init__

createTables(self, *args, **kwargs)

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)

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

str -> str

blobEncode(self, s)

Convert a str object into the necessary object for storing in the database as a blob.

cleanupAssociations(self, *args, **kwargs)

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:
the number of associations expired.
           (type=int)
Overrides:
openid.store.interface.OpenIDStore.cleanupAssociations (inherited documentation)

cleanupNonces(self, *args, **kwargs)

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:
the number of nonces expired.
           (type=int)
Overrides:
openid.store.interface.OpenIDStore.cleanupNonces (inherited documentation)

getAssociation(self, *args, **kwargs)

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

str -> NoneType or Association
Overrides:
openid.store.interface.OpenIDStore.getAssociation

removeAssociation(self, *args, **kwargs)

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

(str, str) -> bool
Overrides:
openid.store.interface.OpenIDStore.removeAssociation

storeAssociation(self, *args, **kwargs)

Set the association for the server URL.

Association -> NoneType
Overrides:
openid.store.interface.OpenIDStore.storeAssociation

txn_createTables(self)

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

txn_getAssociation(self, server_url, handle=None)

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

str -> NoneType or Association

txn_removeAssociation(self, server_url, handle)

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

(str, str) -> bool

txn_storeAssociation(self, server_url, association)

Set the association for the server URL.

Association -> NoneType

txn_useNonce(self, server_url, timestamp, salt)

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

str -> bool

useNonce(self, *args, **kwargs)

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

str -> bool
Overrides:
openid.store.interface.OpenIDStore.useNonce

Class Variable Details

associations_table

This is the default name of the table to keep associations in
Type:
str
Value:
'oid_associations'                                                     

nonces_table

This is the default name of the table to keep nonces in.
Type:
str
Value:
'oid_nonces'                                                           

Generated by Epydoc 2.1 on Wed Apr 22 16:14:20 2009 http://epydoc.sf.net