Update of /cvsroot/sqlobject/SQLObject/SQLObject
In directory sc8-pr-cvs1:/tmp/cvs-serv20597
Modified Files:
Cache.py SQLObject.py
Log Message:
* Fixed Cache problem where it would become interminably locked
* Fixed destroy semantics a little
Index: Cache.py
===================================================================
RCS file: /cvsroot/sqlobject/SQLObject/SQLObject/Cache.py,v
retrieving revision 1.4
retrieving revision 1.5
diff -C2 -d -r1.4 -r1.5
*** Cache.py 10 Apr 2003 21:45:43 -0000 1.4
--- Cache.py 17 Apr 2003 02:59:29 -0000 1.5
***************
*** 105,108 ****
--- 105,110 ----
else:
self.expiredCache[id] = ref(obj)
+
+ def finishPut(self):
self.lock.release()
***************
*** 126,133 ****
--- 128,137 ----
def purge(self, id):
+ self.lock.acquire()
if self.cache.has_key(id):
del self.cache[id]
if self.expiredCache.has_key(id):
del self.expiredCache[id]
+ self.lock.release()
class CacheSet(object):
***************
*** 147,150 ****
--- 151,157 ----
def put(self, id, cls, obj):
self.caches[cls.__name__].put(id, obj)
+
+ def finishPut(self, cls):
+ self.caches[cls.__name__].finishPut()
def created(self, id, cls, obj):
Index: SQLObject.py
===================================================================
RCS file: /cvsroot/sqlobject/SQLObject/SQLObject/SQLObject.py,v
retrieving revision 1.20
retrieving revision 1.21
diff -C2 -d -r1.20 -r1.21
*** SQLObject.py 16 Apr 2003 21:19:03 -0000 1.20
--- SQLObject.py 17 Apr 2003 02:59:29 -0000 1.21
***************
*** 308,314 ****
val = cache.get(id, cls)
if val is None:
! val = object.__new__(cls, id, connection)
! val._init(id, connection)
! cache.put(id, cls, val)
return val
--- 308,317 ----
val = cache.get(id, cls)
if val is None:
! try:
! val = object.__new__(cls, id, connection)
! val._init(id, connection)
! cache.put(id, cls, val)
! finally:
! cache.finishPut(cls)
return val
***************
*** 817,829 ****
clearTable = classmethod(clearTable)
! def destroy(self):
# Kills this object. Kills it dead!
self._SO_obsolete = True
self._SO_autoInitDone = False
- # huh?
- #self._SO_delete(self)
self._connection._SO_delete(self)
self._connection.cache.purge(self.id, self.__class__)
def __repr__(self):
return '<%s %i %s>' \
--- 820,836 ----
clearTable = classmethod(clearTable)
! def destroySelf(self):
# Kills this object. Kills it dead!
self._SO_obsolete = True
self._SO_autoInitDone = False
self._connection._SO_delete(self)
self._connection.cache.purge(self.id, self.__class__)
+ def delete(cls, id):
+ obj = cls(id)
+ obj.destroySelf()
+
+ delete = classmethod(delete)
+
def __repr__(self):
return '<%s %i %s>' \
***************
*** 1071,1075 ****
def getID(obj):
! if type(obj) is type(1):
return obj
elif type(obj) is type(1L):
--- 1078,1084 ----
def getID(obj):
! if isinstance(obj, SQLObject):
! return obj.id
! elif type(obj) is type(1):
return obj
elif type(obj) is type(1L):
***************
*** 1079,1084 ****
elif obj is None:
return None
- else:
- return obj.id
def getObject(obj, klass):
--- 1088,1091 ----
|