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

Class PostgreSQLStore

source code

           object --+        
                    |        
interface.OpenIDStore --+    
                        |    
                 SQLStore --+
                            |
                           PostgreSQLStore

This is a PostgreSQL-based specialization of SQLStore.

To create an instance, see SQLStore.__init__. To create the tables it will use, see SQLStore.createTables.

All other methods are implementation details.

Instance Methods [hide private]
  db_set_assoc(self, server_url, handle, secret, issued, lifetime, assoc_type)
Set an association.
  blobEncode(self, blob)
Convert a str object into the necessary object for storing in the database as a blob.

Inherited from SQLStore: __getattr__, __init__, blobDecode, cleanupAssociations, cleanupNonces, createTables, getAssociation, removeAssociation, storeAssociation, txn_cleanupAssociations, txn_cleanupNonces, txn_createTables, txn_getAssociation, txn_removeAssociation, txn_storeAssociation, txn_useNonce, useNonce

Inherited from interface.OpenIDStore: cleanup

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


Class Variables [hide private]
  create_nonce_sql = '\n CREATE TABLE %(nonces)s (\n server_url VARCHAR(2...
  create_assoc_sql = '\n CREATE TABLE %(associations)s\n (\n server_url V...
  create_settings_sql = '\n CREATE TABLE %(settings)s\n (\n setting VARCHAR(...
  new_assoc_sql = 'INSERT INTO %(associations)s VALUES (%%s, %%s, %%s,...
  update_assoc_sql = 'UPDATE %(associations)s SET secret = %%s, issued = ...
  get_assocs_sql = 'SELECT handle, secret, issued, lifetime, assoc_type...
  get_expired_sql = 'SELECT server_url FROM %(associations)s WHERE issue...
  get_assoc_sql = 'SELECT handle, secret, issued, lifetime, assoc_type...
  remove_assoc_sql = 'DELETE FROM %(associations)s WHERE server_url = %%s...
  clean_assoc_sql = 'DELETE FROM %(associations)s WHERE issued + lifetim...
  add_nonce_sql = 'INSERT INTO %(nonces)s VALUES (%%s, %%s, %%s);'
  clean_nonce_sql = 'DELETE FROM %(nonces)s WHERE timestamp < %%s;'

Inherited from SQLStore: associations_table, nonces_table, settings_table


Properties [hide private]

Inherited from object: __class__


Method Details [hide private]

db_set_assoc(self, server_url, handle, secret, issued, lifetime, assoc_type)

source code 

Set an association. This is implemented as a method because REPLACE INTO is not supported by PostgreSQL (and is not standard SQL).

blobEncode(self, blob)

source code 

Convert a str object into the necessary object for storing in the database as a blob.
Overrides: SQLStore.blobEncode
(inherited documentation)

Class Variable Details [hide private]

create_nonce_sql

Value:
'''
    CREATE TABLE %(nonces)s (
        server_url VARCHAR(2047),
        timestamp INTEGER,
        salt CHAR(40),
        PRIMARY KEY (server_url, timestamp, salt)
    );
    '''                                                                
      

create_assoc_sql

Value:
'''
    CREATE TABLE %(associations)s
    (
        server_url VARCHAR(2047),
        handle VARCHAR(255),
        secret BYTEA,
        issued INTEGER,
        lifetime INTEGER,
...                                                                    
      

create_settings_sql

Value:
'''
    CREATE TABLE %(settings)s
    (
        setting VARCHAR(128) UNIQUE PRIMARY KEY,
        value BYTEA,
        CONSTRAINT value_length_constraint CHECK (LENGTH(value) <= 20)
    );
    '''                                                                
      

new_assoc_sql

Value:
'INSERT INTO %(associations)s VALUES (%%s, %%s, %%s, %%s, %%s, %%s);'  
      

update_assoc_sql

Value:
'UPDATE %(associations)s SET secret = %%s, issued = %%s, lifetime = %%
s, assoc_type = %%s WHERE server_url = %%s AND handle = %%s;'          
      

get_assocs_sql

Value:
'SELECT handle, secret, issued, lifetime, assoc_type FROM %(associatio
ns)s WHERE server_url = %%s;'                                          
      

get_expired_sql

Value:
'SELECT server_url FROM %(associations)s WHERE issued + lifetime < %%s
;'                                                                     
      

get_assoc_sql

Value:
'SELECT handle, secret, issued, lifetime, assoc_type FROM %(associatio
ns)s WHERE server_url = %%s AND handle = %%s;'                         
      

remove_assoc_sql

Value:
'DELETE FROM %(associations)s WHERE server_url = %%s AND handle = %%s;
'                                                                      
      

clean_assoc_sql

Value:
'DELETE FROM %(associations)s WHERE issued + lifetime < %%s;'          
      

add_nonce_sql

Value:
'INSERT INTO %(nonces)s VALUES (%%s, %%s, %%s);'                       
      

clean_nonce_sql

Value:
'DELETE FROM %(nonces)s WHERE timestamp < %%s;'