pyroxide.db.keygen (version 19 , 2006-12-10 23:18:58 -0800 (Sun, 10 Dec 2006) )
index
/usr/lib/python2.4/site-packages/pyroxide/db/keygen.py

Unique key generator module.
 
This is a roll-your-own, database independent key generator.  Obviously,
it would be easier to use Oracle sequences but we are not guaranteed to
be using Oracle.  Also, the automated keys on MySQL are not helpful in 
algorithms where you need the key before the insert.
 
DEPENDENCIES:
 
This class is dependant upon the unitofwork module.  If no UnitOfWork
has been initiated then it shall initiate one automatically.  The UnitOfWork
will provide the database connection for the KeyGenerator class.

 
Modules
       
logging

 
Classes
       
KeyGenerator

 
class KeyGenerator
    A class to generate a unique key within a particular domain class.
 
The keyName must correspond with a domain object and have an entry
in the PKEYS table.  If an invalid keyName is used then a database
error will be returned on the call to nextKey.
 
  Methods defined here:
__init__(self, keyName, incrementBy=1)
Initialize a new KeyGenerator.
 
Raises AssertionError if incrementBy is not a positive integer
nextKey(self)
Return the next key in the key cache.
 
If the next key is the maximum in the cache then we reserve more IDs
from the database.

 
Data
        SQL = 15
__HeadURL__ = '$URL: http://pyroxide.org/svn/pyroxide/trunk/src/main/python/pyroxide/db/keygen.py $'
__Id__ = '$Id: keygen.py 19 2006-12-11 07:18:58Z kevin $'
__LastChangedBy__ = '$Author: kevin $'
__LastChangedDate__ = '$Date: 2006-12-10 23:18:58 -0800 (Sun, 10 Dec 2006) $'
__Revision__ = '$Rev: 19 $'
__author__ = 'Kevin J. Smith (kevin@rootsmith.ca)'
__copyright__ = '(c) 2006 rootsmith Inc.'
__credits__ = ''
__date__ = ' 2006-12-10 23:18:58 -0800 (Sun, 10 Dec 2006) '
__version__ = ' 19 '

 
Author
        Kevin J. Smith (kevin@rootsmith.ca)

 
Credits