On Sunday 12 September 2004 10:25 am, Chris McDonough wrote:
get_transaction().commit(1) commits a "subtransaction". This is used by, for example the Catalog, when doing batch reindexing. You might want to grep for it in the ZCatalog product. There is probably some surrounding hair to try to reduce memory consumption.
Note that explicit transaction control is quite dangerous in Zope if used in the normal course of operations invoked by TTW users (for reasons too obscure to go into here: see recent posts to ZODB-dev). Using it in a script is typically fine though.
Is this the case even for subtransaction commits? I have a particular piece of code that adds a new piece of content to a CMF Site programmatically as the result of a TTW action. During the course of adding the content setId() is called on the object, which fails consistently unless a subtransaction is committed prior to the call (I believe the issue was that the created object wasn't yet stored in the ZODB, so calling setId (which causes a copy) failed). Is this a risky practice? If so, what's the alternative? Thanks. Alec Mitchell