pyroxide.orm.unitofwork (version 29 , 2007-01-17 22:20:11 -0800 (Wed, 17 Jan 2007) )
index
/usr/lib/python2.4/site-packages/pyroxide/orm/unitofwork.py

Unit of Work module.
 
Classes to support the management of business transactions by coordinating
off-line concurrency issues and maintaining knowledge of the state of in-
memory domain objects.

 
Modules
       
logging
threading

 
Classes
       
UnitOfWork
pyroxide.util.singleton.Singleton(__builtin__.object)
ThreadStorage

 
class ThreadStorage(pyroxide.util.singleton.Singleton)
    A thread specific storage class for the Unit of Work pattern.
 
This pattern is based on the Thread-specific storage pattern
by John E. Barham posted to ASPN.
(http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/66429)
 
 
Method resolution order:
ThreadStorage
pyroxide.util.singleton.Singleton
__builtin__.object

Methods defined here:
__init__(self)
Creates a new Storage dictionary.
get(self)
Returns the UnitOfWork for the current thread.
set(self, unitOfWorkArg)
Places the UnitOfWork in the thread storage.

Static methods inherited from pyroxide.util.singleton.Singleton:
__new__(type)

Data and other attributes inherited from pyroxide.util.singleton.Singleton:
__dict__ = <dictproxy object>
dictionary for instance variables (if defined)
__weakref__ = <attribute '__weakref__' of 'Singleton' objects>
list of weak references to the object (if defined)

 
class UnitOfWork
    Unit of Work pattern.
 
Maintains a list of objects that are affected by a business transaction
and coordinates the writing out of the changes and the resolution of
off-line concurrency problems.  This class initiates the database
handle for all operations.
 
  Methods defined here:
__init__(self)
Initializes Unit of Work by creating empty lists.
 
The constructor also associates the current Unit of Work
with the current thread and initiates the DB connection.
abortCurrent(self)
Abort the current UnitWork.
 
Throw out all changes and do NOT commit them to the database.
endCurrent(self, test=False)
End the current UnitOfWork.
 
All the new objects will be inserted, dirty objects updated, and
removed objects deleted by calling the appropriate mapper methods.
Finally, the current UnitOfWork will be removed from the thread
storage.
 
For test cases pass in 1 to prevent writing out to the DB.
getConnection(self)
Return database connection for this UnitOfWork
registerClean(self, obj)
Registers an object as clean.  In essence, do nothing.
 
Raises Error if the object does not yet have unique keys.
registerDirty(self, obj)
Registers an object that has been changed.
 
Raises AssertionError if the object already exists in the removed
objects list or if the object does not yet contain unique keys.
registerNew(self, obj)
Registers a new object.
 
Raises Errors if the object already exists in any of the lists
of dirty objects, removed objects, or new objects.  Also raises an
Error if the object does not yet have unique keys.
registerRemoved(self, obj)
Registers an object as having been removed.
 
Raises Error if the object does not yet have unique keys.

Class methods defined here:
getCurrent(cls) from __builtin__.classobj
Get the UnitOfWork associated to the currently executing thread.
newCurrent(cls) from __builtin__.classobj
Establish a new UnitOfWork.

 
Data
        SQL = 15
__HeadURL__ = '$URL: http://pyroxide.org/svn/pyroxide/trunk/src/main/python/pyroxide/orm/unitofwork.py $'
__Id__ = '$Id: unitofwork.py 29 2007-01-18 06:20:11Z kevin $'
__LastChangedBy__ = '$Author:kevin $'
__LastChangedDate__ = '$Date: 2007-01-17 22:20:11 -0800 (Wed, 17 Jan 2007) $'
__Revision__ = '$Rev: 29 $'
__author__ = 'Kevin J. Smith (kevin@rootsmith.ca)'
__copyright__ = '(c) 2006 rootsmith Inc.'
__credits__ = ''
__date__ = ' 2007-01-17 22:20:11 -0800 (Wed, 17 Jan 2007) '
__version__ = ' 29 '

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

 
Credits