[Zope] How do I commit partial results from an external script?
Max M
maxm@mxm.dk
Fri, 30 Aug 2002 13:50:35 +0200
Toby Dickenson wrote:
>On Friday 30 Aug 2002 11:16 am, Max M wrote:
>
>
>>I need to remove an attribute from most any object in my zodb. I suspect
>>that I will need to do partial commits to not slow down the process to
>>much.
>>
>>Has anybody got an example?
>>
>>
>
>Have a look at how the catalog_object function in ZCatalog.py uses
>subtransactions.
>
>
It was actually quite simple, except that Zope plays a trick. The key to the problem is that "get_transaction()" by magic is a "built in" function in Zope. Also in external methods.
It kind of fazed me that I could not see where get_transaction() was imported from.
Well it wasn't :-s
so I just did something like:
i = 1
transaction = get_transaction()
for obj in aLotOfObjects:
update(obj)
if not i % 200:
transaction.commit(1) # partial transaction
i += 1
regards Max M
"Skeptic Effect" or the "Randi Effect"
When a skeptic is near, supernatural effects seem to disappear.