[ZODB-Dev] conflict resolution for PersistentList

Diez B. Roggisch d.roggisch at ehotel.de
Wed May 26 08:30:48 EDT 2004


Hi,

ok, here comes my example. I use ZODB 3.3a3.

Use conflict_test.py as main program. 

The example should run out of the box if you have installed yaml - otherwise 
uncomment the last import and the first two lines of main().

I'd like to explain how things are working, as the code might look somewhat 
more complicated as necessary. Thats due to the fact that it was created from 
my actual application and tries to mimic the surroundings I've got there.

First of all, the persistent objects in question are ChildData and ParentData. 
ParentData has a prop name and a prop items of type 
ConflictPersistentList(PersistentList). items stores the list of ChildData. 
ChildData has only one prop, payload.

Then there are two proxy-classes, Parent and Child. These access the 
underlying data through a property called _data and by using the class 
ThreadProp. Every property like items is accessed as new-style class property 
through ThreadProp.

The reason for these proxies is that by this I have only one instance of 
Parent/Child. For each thread running, these access their _data through a 
connection local to the current thread. I needed that, as I pass references 
to Parent and Child objects through my corba-interface.

The thread-local connection handling is implemented by using some metaclasses 
in the tas-module. method doc-strings can contain tas::* directives that wrap 
the method up to ensure that proper connection and transaction  handling is 
ensured. The tas-module is roughly modeled after java session beans. Beside 
the wrappers, the main entities are ApplicationContext and Transaction. The 
former can be thought of a session, the latter one encapsulates the 
transaction logic and connection handling. Access to one context is 
serialized for all threads by a RLock.

Then there is the global variable COUNT that counts how many add_child calls 
have been made, so I can detect the difference between the # of calls and the 
# of childs in items.


If you have any questions, feel free to ask. I'm now going to try btrees as 
collection and report on the results later.

And yes, I'm lazy and type _ instead of self - I used to write _name in java 
for instance vars and _.name looks familiar to me.

Regards,

Dies
-------------- next part --------------
A non-text attachment was scrubbed...
Name: cft.tgz
Type: application/x-tgz
Size: 5446 bytes
Desc: not available
Url : http://mail.zope.org/pipermail/zodb-dev/attachments/20040526/e7c4e3cb/cft.bin


More information about the ZODB-Dev mailing list