[Zope-CVS] CVS: Packages/pypes/pypes - identity.py:1.19
Casey Duncan
casey at zope.com
Tue May 25 22:26:20 EDT 2004
Update of /cvs-repository/Packages/pypes/pypes
In directory cvs.zope.org:/tmp/cvs-serv16904
Modified Files:
identity.py
Log Message:
Use insert() method to add items to the identity service
Make sure unregisterable objects do not linger in the identity service
=== Packages/pypes/pypes/identity.py 1.18 => 1.19 ===
--- Packages/pypes/pypes/identity.py:1.18 Mon Apr 12 22:24:32 2004
+++ Packages/pypes/pypes/identity.py Tue May 25 22:26:17 2004
@@ -56,17 +56,18 @@
# Add the object to the database connection so it can be
# used as an access point back to the services
self._p_jar.add(obj)
- # Ids are generated in sequence in a single thread to group
- # related objects in the tree
- while not self._v_nextid or self._objs.has_key(self._v_nextid):
+ while not self._v_nextid or not self._objs.insert(self._v_nextid, obj):
self._v_nextid = randint(-2100000000, 2100000000)
identifier = self._v_nextid
+ # Ids are generated in sequence in a single thread to group
+ # related objects in the tree
try:
obj._pypes_id_ = identifier
except AttributeError:
+ # Remove object from identity mapping immediately
+ del self._objs[identifier]
raise IdentityError, ('Cannot register object. Unable to store '
'persistent id as attribute')
- self._objs[identifier] = obj
self._length.change(1)
self._v_nextid += 1
if self._p_jar is not None:
More information about the Zope-CVS
mailing list