[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
gnue/appserver/src/_featuretest geasObject.py g...
From: |
Jan Ischebeck |
Subject: |
gnue/appserver/src/_featuretest geasObject.py g... |
Date: |
Tue, 14 May 2002 13:21:33 -0400 |
CVSROOT: /cvsroot/gnue
Module name: gnue
Changes by: Jan Ischebeck <address@hidden> 02/05/14 13:21:33
Modified files:
appserver/src/_featuretest: geasObject.py geasTransaction.py
Log message:
odmg compatibility issues
CVSWeb URLs:
http://savannah.gnu.org/cgi-bin/viewcvs/gnue/gnue/appserver/src/_featuretest/geasObject.py.diff?tr1=1.1&tr2=1.2&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/gnue/gnue/appserver/src/_featuretest/geasTransaction.py.diff?tr1=1.1&tr2=1.2&r1=text&r2=text
Patches:
Index: gnue/appserver/src/_featuretest/geasObject.py
diff -c gnue/appserver/src/_featuretest/geasObject.py:1.1
gnue/appserver/src/_featuretest/geasObject.py:1.2
*** gnue/appserver/src/_featuretest/geasObject.py:1.1 Mon May 13 18:34:11 2002
--- gnue/appserver/src/_featuretest/geasObject.py Tue May 14 13:21:33 2002
***************
*** 19,42 ****
# write to the Free Software Foundation, Inc., 59 Temple Place
# - Suite 330, Boston, MA 02111-1307, USA.
#
! # $Id: geasObject.py,v 1.1 2002/05/13 22:34:11 siesel Exp $
from gnue.common import GDebug
import copy
class Error(StandardError):
# Base exception
pass
#
=============================================================================
# Basic class
#
=============================================================================
class geasObject:
#
---------------------------------------------------------------------------
# Initalize
#
---------------------------------------------------------------------------
def __init__ (self, OID, parent_OID):
--- 19,98 ----
# write to the Free Software Foundation, Inc., 59 Temple Place
# - Suite 330, Boston, MA 02111-1307, USA.
#
! # $Id: geasObject.py,v 1.2 2002/05/14 17:21:33 siesel Exp $
from gnue.common import GDebug
import copy
+ class RuntimeError(StandardError):
+ # Base exception
+ pass
+
class Error(StandardError):
# Base exception
pass
+ #
+ # Define basic Locktypes
+ # odl: enum Lock_Type{read, write, upgrade};
+ class readLock:
+ pass
+
+ class writeLock:
+ pass
+
+ class upgradeLock:
+ pass
+
+ class LockNotGrantedError (RuntimeError):
+ pass
+ # Raised if a lock could not be granted. (Note that time-outs
+ # and deadlock detection are implementation defined)
+
+
+ class TransactionAbortedError (RuntimeError):
+ pass
+ # Raised when the database system has asyncronously terminated
+ # the user's transaction due to deadlock, resource failure, and
+ # so on. In such cases the user's data is reset just as if the
+ # user had called Transaction.abort.
+
+ class TransactionInProgressError (RuntimeError):
+ pass
+
+ # Raised when attempting to call a method whithin a transaction
+ # that must be called when no transaction is in progress
+
+ class TransactionNotInProgressError (RuntimeError):
+ pass
+
+ # Raised when attempting to perform outside of a transaction an
+ # operation that must be called when there is a transaction in
+ # progress
+
+
#
=============================================================================
# Basic class
+ #
+ # geasObject provides a simple object which
+ #
+ # * can be object of an transaction
+ # * can be stored and loaded from a database
+ #
+ # it is the basic object type and inheriteds allmost all other objects in the
+ # appserver
+ #
#
=============================================================================
class geasObject:
#
---------------------------------------------------------------------------
# Initalize
+ #
+ # every new object has to be assigned an oid.
+ # OID = object is an unique object identifier
+ # the parent_OID is the OI
#
---------------------------------------------------------------------------
def __init__ (self, OID, parent_OID):
***************
*** 44,65 ****
self._parent_OID = parent_OID
#
---------------------------------------------------------------------------
! # Get the OID of the object from which this is an instance, or
! # from which this is a child object.
! # (just the geasSuperObject has no OID
#
---------------------------------------------------------------------------
! def _isInstanceOf (self):
! # TODO: look up the field type (calculated, reference etc.), translate
! # the field name into a column name
return self._parent_OID
! def lock(self,transaction_id,fullLock=0):
# check if object is allready locked
if hasattr(self,"_writelock"):
# test if object should be readlocked too
! if fullLock==1:
if (self._writelock==transaction_id) and \
not hasattr(self,"_readlock"):
--- 100,128 ----
self._parent_OID = parent_OID
#
---------------------------------------------------------------------------
! # Get the OID of the object from which this is a child, f.e. an instance is
! # an child of a metaobject.
! # (just the geasSuperObject has its own OID as an parentOID)
#
---------------------------------------------------------------------------
! def _isChildOf (self):
return self._parent_OID
!
! # Obtains a specific lock on an object. If an attempt is made
! # to get a lock on an already locked object, this operation
! # will block until the specified lock can be acquired, some
! # time-out threshold is exceeded, or a transaction deadlock is
! # detected. If the time-out threshold is crossed a
! # LockNotGranted exception is raised, If a transaction
! # deadlock is detected, the transaction deadlock exception is raised.
!
! def lock(self,transaction_id,lockType=readLock):
# check if object is allready locked
if hasattr(self,"_writelock"):
# test if object should be readlocked too
! if locktype==1:
if (self._writelock==transaction_id) and \
not hasattr(self,"_readlock"):
***************
*** 68,81 ****
else:
! raise AttributeError, "Object allready read-locked"
else:
! raise AttributeError, "Object allready write-locked"
else:
! # Unlock locked object
#
if (fullLock==1):
self._readlock=transaction_id
--- 131,144 ----
else:
! raise LockNotGrantedError, "Object already read-locked"
else:
! raise LockNotGrantedError, "Object already write-locked"
else:
! # Lock object
#
if (fullLock==1):
self._readlock=transaction_id
***************
*** 83,88 ****
--- 146,174 ----
self._writelock=transaction_id
+
+ # Returns TRUE if specified lock was obtained and FALSE if
+ # the lock is in conflict with an existing lock on the object
+
+ def try_lock(self,transaction_id,lockType):
+ pass
+
+
+ # Compares the identity of this object with another
+
+ def same_as(otherObj):
+ pass
+
+
+ # Creates a new object that is equivalent to the receiver
+ # object, the new object is not the "same_as" the original object
+ def copy():
+ pass
+
+ # Explicitly deletes an object from an ODMS by removing it
+ # from memory in addition to the ODMS
+ def delete():
+ pass
def releaseLock(self,transaction_id,changed_obj=None):
***************
*** 108,119 ****
raise AttributeError, "Object not locked by this transaction"
! def getWriteableCopy(self,transaction_id):
mycopy=copy.copy(self)
mycopy.__dict__["__writable__"]=true
return mycopy
! def getOriginalObject(self):
if hasattr(self,"_original"):
return self._original
else:
--- 194,205 ----
raise AttributeError, "Object not locked by this transaction"
! def _getWriteableCopy(self,transaction_id):
mycopy=copy.copy(self)
mycopy.__dict__["__writable__"]=true
return mycopy
! def _getOriginalObject(self):
if hasattr(self,"_original"):
return self._original
else:
***************
*** 125,133 ****
def setLifeTimeType(self,type):
self._lifeTimeType=type
- #
---------------------------------------------------------------------------
- # Call a method
- #
---------------------------------------------------------------------------
-
- def __call__ (self, methodname):
- pass
--- 211,213 ----
Index: gnue/appserver/src/_featuretest/geasTransaction.py
diff -c gnue/appserver/src/_featuretest/geasTransaction.py:1.1
gnue/appserver/src/_featuretest/geasTransaction.py:1.2
*** gnue/appserver/src/_featuretest/geasTransaction.py:1.1 Mon May 13
18:34:11 2002
--- gnue/appserver/src/_featuretest/geasTransaction.py Tue May 14 13:21:33 2002
***************
*** 19,25 ****
# write to the Free Software Foundation, Inc., 59 Temple Place
# - Suite 330, Boston, MA 02111-1307, USA.
#
! # $Id: geasTransaction.py,v 1.1 2002/05/13 22:34:11 siesel Exp $
from gnue.common import GDebug
--- 19,25 ----
# write to the Free Software Foundation, Inc., 59 Temple Place
# - Suite 330, Boston, MA 02111-1307, USA.
#
! # $Id: geasTransaction.py,v 1.2 2002/05/14 17:21:33 siesel Exp $
from gnue.common import GDebug
***************
*** 36,48 ****
def __init__ (self, OID, parent_OID):
self._OID = OID
self._parent_OID = parent_OID
! self._status="begin"
self._cache={}
#
---------------------------------------------------------------------------
! # Get the OID of the object from which this is an instance, or
! # from which this is a child object.
! # (just the geasSuperObject has no OID
#
---------------------------------------------------------------------------
def addToTransactionCache (self,oid,object):
--- 36,61 ----
def __init__ (self, OID, parent_OID):
self._OID = OID
self._parent_OID = parent_OID
! self._isOpen=false
self._cache={}
+ #
---------------------------------------------------------------------------
+ # After a transaction object is created, it is initially
+ # closed. An explicit 'begin' operation is required to open a
+ # transaction. If the transaction is already open, and additional calls
+ # to 'begin' operations raise the 'TransactionInProgress' exception
#
---------------------------------------------------------------------------
!
! def begin():
! if self._isOpen:
! raises TransactionInProgressError
! else:
! self._cache={}
! self._isOpen=true
!
! #
---------------------------------------------------------------------------
! # add an Object to the transaction cache.
! # the transaction cache is the place where local objects get stored
#
---------------------------------------------------------------------------
def addToTransactionCache (self,oid,object):
***************
*** 62,67 ****
--- 75,82 ----
# (in case of lock=true)
# d) it returns that object
#
+ #
---------------------------------------------------------------------------
+
def getObject(self,oid,lock=true):
try:
return self._cache[oid]
***************
*** 77,95 ****
else:
return o
def commit(self):
! for o in self._cache:
! orginal=o.getOrginalObject()
! orginal=o.releaseLock(self,self._OID,o)
! self.status="commited"
! self._cache={}
def rollback(self):
! for o in self._cache:
! orginal=o.getOrginalObject()
! orginal=o.releaseLock(self,self._OID,None)
! self.status="rollback"
! self._cache={}
--- 92,186 ----
else:
return o
+ #
---------------------------------------------------------------------------
+ # Checks to see if the transaction object is "open" i.e. begin() has been
+ # called.
+ #
---------------------------------------------------------------------------
+
+ def isOpen():
+ return self._isOpen
+
+ #
---------------------------------------------------------------------------
+ # Causes all persistent objects created or modified during the
+ # transaction to be written to the ODMS and to become accessible to
+ # other Transaction objects running against that ODMS. All locks held
+ # by the Transaction object are released. Finally, it causes the
+ # Transaction object to complete and become closed. The
+ # TransactionNotInProgress exception is raised if a 'commit' operation
+ # is executed on a closed transaction object
+ #
---------------------------------------------------------------------------
def commit(self):
! if self._isOpen:
! for o in self._cache:
! orginal=o.getOrginalObject()
! orginal=o.releaseLock(self,self._OID,o)
! self._isOpen=false
! self._cache={}
! else:
! raise TransactionNotInProgressError
!
!
+ #
---------------------------------------------------------------------------
+ # Causes the Transaction object to complete and become closed. The ODMS
+ # is returned to the state it was in prior to the beginning of the
+ # transaction. All locks held by the Transaction object are
+ # released. The TransactionNotInProgress exception is raised if an
+ # abort operation is executed on a closed Transaction object
+ #
---------------------------------------------------------------------------
+
def rollback(self):
! if self._isOpen:
! for o in self._cache:
! orginal=o.getOrginalObject()
! orginal=o.releaseLock(self,self._OID,None)
! self._isOpen=false
! self._cache={}
! else:
! raise TransactionNotInProgressError
!
+
+ #
---------------------------------------------------------------------------
+ # This operation is equivalent to a commit operation followed by a
+ # begin operation, except that locks held by the Transaction object are
+ # not released, Therefore, it causes all modified objects to be
+ # committed to the ODMS, and it retains all locks held by the
+ # Transaction object The Transaction object remains open. The
+ # TransactionNotInProgress exception is raised if a checkpoint
+ # operation executed on a closed Transaction object
+ #
---------------------------------------------------------------------------
+ void checkpoint() raises(TransactionNotInProgress);
+ if self._isOpen:
+ for o in self._cache:
+ orginal=o.getOrginalObject()
+ orginal=o._updateObject(self,o)
+ else:
+ raise TransactionNotInProgressError
+
+
+ # ODMS operations are always executed within the context of a
+ # transaction. Therefore, to execute any operations on persistent
+ # objects, and active Transaction object must be associated with the
+ # current thread. The join operation associates the current thread with
+ # a Transaction object. If the Transaction object is open, persistent
+ # object operations may be executed; otherwise a TransactioNotInProgress
+ # exception is raised
+ # void join() raises(TransactionNotInProgress);
+ # will be handled by the session object
+
+ # If an implementation allows multiple active Transaction objects to
+ # exist, the join and leave operations allow a thread to alternate
+ # between them. To associate the current thread with another
+ # Transaction object, simply execute a join on the new Transaction
+ # object If necessary, a leave operation is automatically executed to
+ # dissociate the current thread from its current Transaction
+ # object. Moving from one transaction object to another does not commit
+ # or abort a Transaction object. When the current thread has no current
+ # transaction object, the leave operation is ignored.
+ # void leave() raises(TransactionNotInProgress);
+ # will be handled by the session object
+
+
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- gnue/appserver/src/_featuretest geasObject.py g...,
Jan Ischebeck <=