Script (python) shows transaction for adding folder
I have a script that accepts an html form entry (submitted from a dtml-document) and tries to do various file uploads into the zodb (actually, they are ExtImages). All of this works (pretty well), but in testing, I've noticed that each time my script performs this form validation/submission process, there is a new transaction present in the undo list. The transaction refers to adding a folder (and probably another one to add the actual image) to the zodb for the upload. So, my question is, why does the transaction appear in the undo list for the script, and not the parent folder I'm adding to (which is a BTree folder if that makes any difference)? I guess it's not a problem, just seems a bit odd to me. thanks tim
Tim Hicks writes:
... Script performs actions on folder ... The transaction refers to adding a folder (and probably another one to add the actual image) to the zodb for the upload. So, my question is, why does the transaction appear in the undo list for the script, and not the parent folder I'm adding to (which is a BTree folder if that makes any difference)? Strange:
I would expect that you get only a single transaction - for the script, because there is just one transaction per request. I would further expect that the transaction machinery is not intelligent enough to assiciate the transaction with the correct object in all cases. E.g. a single Script can change many objects all over the site. Dieter
Tim Hicks writes:
... Script performs actions on folder ... The transaction refers to adding a folder (and probably another one to add the actual image) to the zodb for the upload. So, my question is, why does the transaction appear in the undo list for the script, and not the parent folder I'm adding to (which is a BTree folder if that makes any difference)? Strange:
I would expect that you get only a single transaction - for the script, because there is just one transaction per request.
Sorry, that was me making assumptions. The script creates a folder (if necessary), then deposits an ExtImage into if there has been one uploaded. In my tests, there was no uploaded file, so only the folder was created. I saw a transaction for this, and *assumed* I would see one for the file upload as well if there were one present.
I would further expect that the transaction machinery is not intelligent enough to assiciate the transaction with the correct object in all cases. E.g. a single Script can change many objects all over the site.
OK, I think I understand a bit better now. Given the 'one transaction per request' that you mention, it makes sense that the transaction (that could have affected multiple objects) be associated with the script. This is mildly annoying as it will probably make the undo list huge for the script, which will probably drown a the actual changes to the script that I may make periodically. Aah well, such is life. thanks tim
participants (2)
-
Dieter Maurer -
Tim Hicks