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

Class SQLStore

source code

           object --+    
                    |    
interface.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 settings_table, 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 [hide private]
  __init__(self, conn, settings_table=None, associations_table=None, nonces_table=None)
This creates a new SQLStore instance.
  createTables(self, *args, **kwargs)
This method creates the database tables necessary for this store to work.
  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.
  __getattr__(self, attr)
  txn_createTables(self)
This method creates the database tables necessary for this store to work.
  txn_getAuthKey(self)
Get the key for this consumer to use to sign its own communications.
str getAuthKey(self, *args, **kwargs)
Get the key for this consumer to use to sign its own communications.
  txn_storeAssociation(self, server_url, association)
Set the association for the server URL.
NoneType storeAssociation(self, *args, **kwargs)
Set the association for the server URL.
  txn_getAssociation(self, server_url, handle=None)
Get the most recent association that has been set for this server URL and handle.
Association or NoneType getAssociation(self, *args, **kwargs)
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.
bool or int removeAssociation(self, *args, **kwargs)
Remove the association for the given server URL and handle, returning whether the association existed at all.
  txn_storeNonce(self, nonce)
Add this nonce to the set of extant nonces, ignoring if it is already present.
NoneType storeNonce(self, *args, **kwargs)
Add this nonce to the set of extant nonces, ignoring if it is already present.
  txn_useNonce(self, nonce)
Return whether this nonce is present, and if it is, then remove it from the set.
bool or int useNonce(self, *args, **kwargs)
Return whether this nonce is present, and if it is, then remove it from the set.

Inherited from interface.OpenIDStore: isDumb

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


Class Variables [hide private]
  settings_table = 'oid_settings'
This is the default name of the table to keep this store's settings in.
  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.

Inherited from interface.OpenIDStore: AUTH_KEY_LEN


Properties [hide private]

Inherited from object: __class__


Method Details [hide private]

__init__(self, conn, settings_table=None, 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.
  • settings_table (str) - This is an optional parameter to specify the name of the table used for this store's settings. The default value is specified in SQLStore.settings_table.
  • 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

blobEncode(self, s)

source code 

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

__getattr__(self, attr)
(Qualification operator)

source code 

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_getAuthKey(self)

source code 

Get the key for this consumer to use to sign its own communications. This function will create a new key if one does not yet exist.

() -> str

getAuthKey(self, *args, **kwargs)

source code 

Get the key for this consumer to use to sign its own communications. This function will create a new key if one does not yet exist.

() -> str
Returns: str
The key. It should be AUTH_KEY_LEN bytes in length, and use the full range of byte values. That is, it should be treated as a lump of binary data stored in a str instance.
Overrides: interface.OpenIDStore.getAuthKey

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
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
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
Returns: bool or int
Returns whether or not the given association existed.
Overrides: interface.OpenIDStore.removeAssociation

txn_storeNonce(self, nonce)

source code 

Add this nonce to the set of extant nonces, ignoring if it is already present.

str -> NoneType

storeNonce(self, *args, **kwargs)

source code 

Add this nonce to the set of extant nonces, ignoring if it is already present.

str -> NoneType
Returns: NoneType
None
Overrides: interface.OpenIDStore.storeNonce

txn_useNonce(self, nonce)

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
Returns: bool or int
Whether or not the nonce was valid.
Overrides: interface.OpenIDStore.useNonce

Class Variable Details [hide private]

settings_table


This is the default name of the table to keep this store's settings in.
Value:
'oid_settings'                                                         
      

associations_table


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

nonces_table


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