Plone api persistance

An explicit commit() is only necessary if you handle the ZODB connection yourself e.g. when you write a script that you run under control e.g. through bin/instance run yourscript.py. There is no need to commit or abort a transaction yourself inside your own code running directly within a "normally" started Plone instance. The underlaying Zope application server will commit/abort (in case of an exception) automatically after the end of each HTTP request for you. And in particular it is not recommended to perform any commit/abort operations yourself e.g. inside browser views. It is allowed to perform subtransactions e.g. when you deal with large amounts of data. But the general rule is that NO commit/abort statement should be contained inside Plone code (e.g. inside policy packages). Only code wrapping policy package calls like scripts controlled by bin/instance run .. should and must do the transaction handling themselves.

1 Like