[Zope-Coders] Zope test results

Shane Hathaway shane@zope.com
Wed, 12 Jun 2002 12:19:45 -0400


Jeremy Hylton wrote:
>>>>>>"SH" == Shane Hathaway <shane@zope.com> writes:
>   SH> 1) Connection.register(object) will set the _p_jar (and perhaps
>   SH>    _p_oid)
>   SH> of the object, if it has not already been set, then call
>   SH> get_transaction().register(object).  cPersistence will call
>   SH> _p_jar.register() instead of get_transaction().register().
> 
>   SH> 2) Connection.register(object) will set the _p_jar (and perhaps
>   SH>    _p_oid)
>   SH> of the object.  It will simply return.  cPersistence will not
>   SH> change.
> 
>   SH> I'd really like to see option 1, since in my own ZODB
>   SH> experiments I've frequently had to patch Transaction.register().
>   SH> If I could just override Connection.register() in my subclass,
>   SH> the code would be much cleaner.  I think the performance impact
>   SH> would be very small.
> 
> I had been thinking about option 2, but I hadn't given it much
> thought.  What changes have you had to make to Transaction.register()?

In one experiment, I provided a way to perform conflict resolution of an 
entire branch of objects (as opposed to single-object conflict 
resolution like we have today).  I used a custom Connection type for all 
objects in a part of the database.  I had to patch 
Transaction.register() to channel object change notifications to a 
different place.  If cPersistence called connection.register() instead, 
I would have been able to simply override instead.

Hmm, come to think of it, I guess that's the only experiment that needed 
this. ;-)  But I think there are other reasons to do it this way. 
cPersistence currently expects to find a get_transaction() builtin, but 
if it instead called a method of the connection, it wouldn't depend 
directly on that controversial builtin.  Also, I imagine having two 
public methods called register(), but which do slightly different 
things, might be confusing for StandaloneZODB application developers. 
If one calls the other, it's clearer.

Shane