[ZODB-Dev] [ZODB4] - Shouldn't the new object be added to Connection._created ?

Jim Fulton jim@zope.com
Mon, 08 Jul 2002 08:26:14 -0400


Ury Marshak wrote:
> [ZODB4] - Shouldn't the new object be added to Connection._created  ?
> 
> While digging around looking for the source of my ZEO-ZODB4
> trouble... found something fishy ....  again ;) ... 
> 
> ZODB/Connection.py :
> 
> ........................
> def new_persistent_id(self, stack):
> ............... around line 700 in Connection.py ..........
>         if oid is None or object._p_jar is not self:
>             oid = self.new_oid()
>             object._p_jar = self
>             object._p_oid = oid
>             stack.append(object)            # <------- here
>         klass = object.__class__
> 
> It seems that we have a new object inserted here.
> Shouldn't it have a ' self._created.append(oid) '  line here,
> so that the object would be invalidated on transaction abort ??
> Something like this:
>         if oid is None or object._p_jar is not self:
>             oid = self.new_oid()
>             object._p_jar = self
>             object._p_oid = oid
>             stack.append(object)
>             self._created.append(oid)
>         klass = object.__class__
> 

No, the object will be added to the created list in commit_store,
where the stack is processed,

Note that, if the transaction is aborted, the reference to the new object
will go away and it will disappear, so it doesn't really need to be
invalidated. You don't need to keep track of created objects until they
have been assigned oids.

Jim


-- 
Jim Fulton           mailto:jim@zope.com       Python Powered!
CTO                  (888) 344-4332            http://www.python.org
Zope Corporation     http://www.zope.com       http://www.zope.org