[Zope-Checkins] CVS: Zope/lib/python/Products/Transience - TransientObject.py:1.8
Chris McDonough
chrism@zope.com
Mon, 24 Jun 2002 15:31:17 -0400
Update of /cvs-repository/Zope/lib/python/Products/Transience
In directory cvs.zope.org:/tmp/cvs-serv2104
Modified Files:
TransientObject.py
Log Message:
Changed transient object invalidate() method to search acquisition
chain for its transient object container.
Changed session data manager to splice itself into the transient
object container's acquisition path before returning a session
data object via getSessionData.
Updated unit tests to reflect changes.
=== Zope/lib/python/Products/Transience/TransientObject.py 1.7 => 1.8 ===
import time, random, sys
from TransienceInterfaces import ItemWithId, Transient, DictionaryLike,\
- TTWDictionary, ImmutablyValuedMappingOfPickleableObjects
+ TTWDictionary, ImmutablyValuedMappingOfPickleableObjects,\
+ TransientItemContainer
from AccessControl import ClassSecurityInfo
import Globals
from zLOG import LOG, BLATHER, INFO
@@ -77,7 +78,13 @@
if hasattr(self, '_invalid'):
# we dont want to invalidate twice
return
- trans_ob_container = getattr(self, 'aq_parent', None)
+ trans_ob_container = None
+ # search our acquisition chain for a transient object container
+ # and delete ourselves from it.
+ for ob in getattr(self, 'aq_chain', []):
+ if TransientItemContainer.isImplementedBy(ob):
+ trans_ob_container = ob
+ break
if trans_ob_container is not None:
if trans_ob_container.has_key(self.token):
del trans_ob_container[self.token]