[ZODB-Dev] zodb4: adding an object before transaction commit

Christian Reis kiko at async.com.br
Mon Oct 6 11:19:45 EDT 2003


On Mon, Oct 06, 2003 at 06:13:55PM +0300, Steve Alexander wrote:
> I want to do some things with the oids of persistent objects, such as 
> use them as keys in a BTree.
> 
> The thing is that an object doesn't get an oid until it is added to the 
> database, and a transaction is committed.
> 
> I'd like a way of saying to a data manager (_p_jar) that I intend to add 
> an object to the database, so the data manager can provide that object 
> with a suitable _p_jar and _p_oid. The oid would remain as set if the 
> object is attached to the database's root object (possibly via other 
> objects), and a transaction comimtted.

I *strongly* agree here. This is a *very* important issue (we have to
provide special keys for our objects to work around this, and delay
inserting objects into the BTree until we can provide it -- hacks upon
hacks).

I'm fine with the proposed add() API. 

> I chatted briefly with Jim Fulton about this. An API such as 
> Connection.add(object) was suggested. For example:
> 
>   >>> f = Foo()
>   >>> f
>   <Some persistent object>
>   >>> f._p_oid
>   >>> f._p_jar
>   >>> root_object._p_jar.add(f)
>   >>> f._p_oid
>   'somevalidoid'
>   >>> f._p_jar
>   <some valid Connection>
> 
> I guess 'add' would raise a TypeError if the object you want to add is 
> not a Persistent object.

(My only extra wish would be adding this before the ZODB4 timeframe :-)

Take care,
--
Christian Reis | http://async.com.br/~kiko/ | [+55 16] 261 2331



More information about the ZODB-Dev mailing list