[ZODB-Dev] question

Dieter Maurer dieter at handshake.de
Wed Sep 17 14:47:57 EDT 2003


Christian Reis wrote at 2003-9-17 13:12 -0300:
 > ...
 > > Why do you not use a *separate* transaction to manage your "out of band"
 > > objects?
 > 
 > That would be a solution, but my objects aren't really out of band. I
 > just want to be able to choose to save them separately. 

"Out of band" was the term I used for "not in the main transaction"...

 > In my example, a Sale object holds a reference to a Customer, but if the
 > sale is cancelled, I still want to be able to save the customer's data.
 > 
 > I can't use a separate transaction to edit the Customer because I would
 > need to call sync() on *Sale's* transaction in order to load the
 > Customer's fresh changes. This, in turn, would invalidate the changes I
 > made to Sale.

When the transaction (modifying "Sale") does not modify
"Customer", there is a way to get fresh changes (although your
application seems a bit broken, when you really need that).

With "customer._p_deactivate()" you can flush "customer" from
the ZODB cache. When you later access it again, it will be
reloaded.
Usually, Zope will raise a "ReadConflictError" when the
object has been modified since transaction start.
You can prevent this by giving your class a true
"_p_independent" attribute.

In this way, you may see changing values for the same object
in the same transaction. Usually, this is not a good
idea. But, when you know what you are doing...

The "_p_independent" will allow "Customer" objects to
be read independent of invalidation notifications *everywhere*
in your application and not only in the special transaction
modifying "Sales". You may want to use a specialized
Connection to get more control over this behaviour.

 > ...
 > > You may also want to use MVCC (Multi Version Concurrency Control)
 > > (e.g. as implemented in my "No more ReadConflictErrors" patch) as
 > > otherwise, long living transactions may see a higher probability
 > > of ReadConflictErrors.
 > 
 > I've read about your patch before on the list, but I never tried it

As I understand your requirements now, it would not help you.


Dieter



More information about the ZODB-Dev mailing list