[Zodb-checkins] CVS: Zope3/lib/python/ZODB - Connection.py:1.60.6.11
Jim Fulton
jim@zope.com
Wed, 13 Mar 2002 17:49:29 -0500
Update of /cvs-repository/Zope3/lib/python/ZODB
In directory cvs.zope.org:/tmp/cvs-serv30140
Modified Files:
Tag: Zope-3x-branch
Connection.py
Log Message:
Fixed an incorrect check for a persistent class.
Removed some evil code that unwrapped acquisition-wrapped objects.
Resolved some XXX comments.
=== Zope3/lib/python/ZODB/Connection.py 1.60.6.10 => 1.60.6.11 ===
self._created.append(oid)
else:
- #XXX We should never get here
- #jer: Don't understand previous comment.
+ # We should only get here for the original object passed to commit
if ((self._invalidated.has_key(oid) and
not hasattr(pobject, '_p_resolveConflict'))
or self._invalidated.has_key(None)):
@@ -448,7 +447,7 @@
# It's unclear what exactly this conditional is testing and
# why it takes one branch or the other. It looks like a
# Persistent object will never has it's __getstate__() called.
- if pobject is type:
+ if issubclass(klass, type): # XXX is this a persistent class
dict = {}
dict.update(pobject.__dict__)
# XXX we delete the _p_jar, but not, say, _p_oid?
@@ -456,7 +455,6 @@
args = pobject.__name__, pobject.__bases__, dict
state = None
else:
- # XXX For what kind of object is this path taken?
if hasattr(klass, '__getinitargs__'):
args = pobject.__getinitargs__()
len(args) # XXX Assert it's a sequence
@@ -478,15 +476,7 @@
# Put the object in the cache before handling the
# response, just in case the response contains the
# serial number for a newly created object
- try:
- self._cache[oid] = pobject
- except:
- # Dang, I bet its wrapped:
- # jer: Why does this mean?
- if hasattr(pobject, 'aq_base'):
- self._cache[oid] = pobject.aq_base
- else:
- raise
+ self._cache[oid] = pobject
self._handle_serial(s, oid)
def commit_sub(self, t):
@@ -664,8 +654,9 @@
self.cacheGC() # This is a good time to do some GC
def exchange(self, old, new):
- # XXX This seems to exist only to support ZClasses.
- # replace old's cache entry with new
+ # Replace an existing object with a new one.
+ # This is used by ZClasses to support some deep
+ # hacking to allow base classes to change.
oid = old._p_oid
new._p_oid = oid
new._p_jar = self