Please have a look at this class

Bruno Desthuilliers bruno.42.desthuilliers at wtf.websiteburo.oops.com
Thu Jan 25 10:31:06 EST 2007


antred a écrit :
> Hello everyone,
> 
> While working on a program I encountered a situation where I'd
> construct a largish data structure (a tree) from parsing a host of
> files and would end up having to throw away parts of my newly built
> tree if a file turned out to contain invalid data. My first thought was
> 'Well, you can always make a deep copy of your tree first, then add new
> data to the copy and revert to the original if you need to.", but as
> this tree can grow very big this is not exactly efficient.
> So my second idea was to come up with a class that offers a very
> limited degree of database-like behavior, meaning you can make changes
> to the object and then decide whether you want to commit those changes
> or roll them back to get back to the original. 

Then you may want to have a look at the zodb (and possibly Durus - it 
has support for transactions too IIRC) instead of reinventing the square 
wheel.



More information about the Python-list mailing list