[Zope-Coders] Zope test results

Shane Hathaway shane@zope.com
Wed, 12 Jun 2002 10:21:13 -0400


Guido van Rossum wrote:
>>I'd talk to you directly but I may as well let others know who are 
>>interested. ;-)  There are certain times when you'd like to create an 
>>object and, within the same transaction, make a copy of it. 
>>Unfortunately, it doesn't work if _p_jar isn't set.  So I added that 
>>little hack many moons ago.
>>
>>But I think I know the right solution now: commit a subtransaction just 
>>before copying.  The _p_jar (and _p_oid) of all new objects will be set. 
>>  It should be perfectly safe since copying involves a subtransaction 
>>anyway, so now we'll just be using two subtransactions instead of one. 
>>I'll work on it.
> 
> 
> I may be missing something fundamental here, but why is committing a
> subtransaction in order to be able to copy not a hack?

Copying is done at the storage level, to make copying a large number of 
objects efficient.  To make a copy of current data rather than the data 
as it was at the beginning of the transaction, you need to store the 
current data, but you don't want to commit the whole transaction, hence 
a subtransaction.

That said, the whole thing might be simpler if copying were done at the 
application level instead. ;-)  But the current strategy works well enough.

Shane