[Zope-CVS] CVS: Packages/pypes/pypes - extent.py:1.7 graph.py:1.8
identity.py:1.11
Casey Duncan
casey at zope.com
Sun Feb 29 00:44:50 EST 2004
Update of /cvs-repository/Packages/pypes/pypes
In directory cvs.zope.org:/tmp/cvs-serv18246
Modified Files:
extent.py graph.py identity.py
Log Message:
Use new connection.add() method instead of assigning to _p_jar
Add this api to the zodb test scaffold
Add test that identified objects are added to the zodb conn before commit
=== Packages/pypes/pypes/extent.py 1.6 => 1.7 ===
--- Packages/pypes/pypes/extent.py:1.6 Sun Feb 22 01:09:31 2004
+++ Packages/pypes/pypes/extent.py Sun Feb 29 00:44:48 2004
@@ -199,7 +199,7 @@
self._subclasses = OOBTree() # Map class key => set of subclass keys
self._instances = OOBTree() # Map class key => id set of instances
listenForIdEvents(self, dbconn)
- self._p_jar = dbconn # Allow service access before commit
+ dbconn.add(self) # Allow service access before commit
#self.update(dbconn)
def __getitem__(self, key):
@@ -240,8 +240,6 @@
except KeyError:
# Instance of class not yet seen
instances = self._instances[key] = IdentitySet()
- # Allow service access by instances set before commit
- instances._p_jar = getattr(self, '_p_jar', None)
self._addClass(cls)
instances.add(obj)
=== Packages/pypes/pypes/graph.py 1.7 => 1.8 ===
--- Packages/pypes/pypes/graph.py:1.7 Fri Jan 30 00:35:38 2004
+++ Packages/pypes/pypes/graph.py Sun Feb 29 00:44:48 2004
@@ -630,14 +630,13 @@
super(DirectedIdGraphEdges, self).__init__()
def add(self, source, target, value=_marker):
- if self._p_jar is None:
- # Grab the data manager from the obj passed so
+ if self._p_jar is None and getattr(source, '_p_jar', None) is not None:
+ # Add ourself to the connection from the obj passed so
# we have access to the services before we are committed
- conn = getattr(source, '_p_jar', None)
- self._p_jar = conn
+ source._p_jar.add(self)
if (self._v_graph is not None
and self._v_graph.nodes._p_jar is None):
- self._v_graph.nodes._p_jar = conn
+ source._p_jar.add(self._v_graph.nodes)
src_ident, tgt_ident = pypesid(source), pypesid(target)
if src_ident is None:
raise IdentityError, source
@@ -715,14 +714,13 @@
self._node_count = graph.edges._node_count
def add(self, obj):
- if self._p_jar is None:
- # Grab the data manager from the obj passed so
+ if self._p_jar is None and getattr(obj, '_p_jar', None) is not None:
+ # add ourself to the connection from the obj passed so
# we have access to the services before we are committed
- conn = getattr(obj, '_p_jar', None)
- self._p_jar = conn
+ obj._p_jar.add(self)
if (self._v_graph is not None
and self._v_graph.edges._p_jar is None):
- self._v_graph.edges._p_jar = conn
+ obj._p_jar.add(self._v_graph.edges)
ident = pypesid(obj)
if ident is None:
raise IdentityError, obj
=== Packages/pypes/pypes/identity.py 1.10 => 1.11 ===
--- Packages/pypes/pypes/identity.py:1.10 Sun Feb 22 00:39:04 2004
+++ Packages/pypes/pypes/identity.py Sun Feb 29 00:44:48 2004
@@ -54,9 +54,9 @@
if pypesid(obj) is not None:
raise IdentityError, 'Object already registered'
if self._p_jar is not None and getattr(obj, '_p_jar', 0) is None:
- # Make sure the object has a data manager so it can be
+ # Add the object to the database connection so it can be
# used as an access point back to the services
- obj._p_jar = self._p_jar
+ 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):
@@ -162,15 +162,15 @@
else:
set._idset = idset
if dbconn is not None:
- set._p_jar = dbconn
+ dbconn.add(set)
return set
fromIdSet = classmethod(fromIdSet)
def add(self, obj):
- if self._p_jar is None:
- # Grab the data manager from the obj passed so
- # we have access to the services before we are committed
- self._p_jar = getattr(obj, '_p_jar', None)
+ if self._p_jar is None and getattr(obj, '_p_jar', None) is not None:
+ # If we are not associated with a database connection
+ # add us to onr from the child object so we can access services
+ obj._p_jar.add(self)
ident = pypesid(obj)
if ident is None:
raise IdentityError, obj
More information about the Zope-CVS
mailing list