

![]() | Start a set with this search |
![]() | Include this search in one of my sets |
![]() | Exclude this search from one of my sets |
![]() | Permalink to these results Paste this link in email or IM: |
| Atom feed for tracking future search results Paste this URL into your reader: |
37 messages in net.sourceforge.lists.plone-developersRe: CMFFormController should abort th...| From | Sent On | Attachments |
|---|---|---|
| Dorneles Treméa | Nov 9, 2007 3:17 pm | |
| Philipp von Weitershausen | Nov 10, 2007 7:07 am | |
| Dorneles Treméa | Nov 10, 2007 7:58 am | |
| Wichert Akkerman | Nov 10, 2007 12:22 pm | |
| Martin Aspeli | Nov 10, 2007 2:12 pm | |
| Wichert Akkerman | Nov 10, 2007 4:20 pm | |
| Philipp von Weitershausen | Nov 11, 2007 1:32 am | |
| Dorneles Treméa | Nov 11, 2007 5:19 pm | |
| Alan Runyan | Nov 11, 2007 5:20 pm | |
| Martin Aspeli | Nov 11, 2007 5:44 pm | |
| Martin Aspeli | Nov 11, 2007 5:51 pm | |
| Wichert Akkerman | Nov 12, 2007 4:37 am | |
| Sidnei da Silva | Nov 12, 2007 4:43 am | |
| Daniel Kraft | Nov 12, 2007 5:40 am | |
| Martin Aspeli | Nov 12, 2007 5:52 am | |
| Dorneles Treméa | Nov 12, 2007 9:35 am | |
| Wichert Akkerman | Nov 12, 2007 9:56 am | |
| Martin Aspeli | Nov 12, 2007 9:59 am | |
| Martin Aspeli | Nov 12, 2007 10:00 am | |
| Dorneles Treméa | Nov 12, 2007 10:56 am | |
| Martin Aspeli | Nov 12, 2007 11:14 am | |
| Martin Aspeli | Nov 12, 2007 11:21 am | |
| Wichert Akkerman | Nov 12, 2007 11:36 am | |
| Martin Aspeli | Nov 12, 2007 11:41 am | |
| Sidnei da Silva | Nov 12, 2007 11:47 am | |
| Martin Aspeli | Nov 12, 2007 12:04 pm | |
| Dorneles Treméa | Nov 12, 2007 12:28 pm | |
| Dorneles Treméa | Nov 12, 2007 12:34 pm | |
| Dorneles Treméa | Nov 12, 2007 1:29 pm | |
| Wichert Akkerman | Nov 12, 2007 1:32 pm | |
| Martin Aspeli | Nov 12, 2007 1:41 pm | |
| Dorneles Treméa | Nov 12, 2007 1:44 pm | |
| Martin Aspeli | Nov 12, 2007 1:46 pm | |
| Wichert Akkerman | Nov 12, 2007 1:46 pm | |
| Martin Aspeli | Nov 12, 2007 1:47 pm | |
| Dorneles Treméa | Nov 12, 2007 5:11 pm | |
| Daniel Nouri | Nov 13, 2007 4:14 am |

![]() | Permalink for this message Paste this link in email or IM: |
![]() | Permalink for this thread Paste this link in email or IM: |
| Atom feed for this thread Paste this URL into your reader: |
| Subject: | Re: CMFFormController should abort the current transaction when the validation fails | Actions... |
|---|---|---|
| From: | Martin Aspeli (opti...@public.gmane.org) | |
| Date: | Nov 11, 2007 5:51:46 pm | |
| List: | net.sourceforge.lists.plone-developers | |
Dorneles Treméa wrote:
Hello,
Do you have an example of where that would happen? I am not convinced that a change in behaviour like that will not break existing sites.
It would only happen if
a) the validator saves data
b) the data save happens even if the validator failed
In both cases, it's an explicit decision (or a bug).
exactly, and I'm advocating it's a real bug... :-)
No, I mean, it's a (serious, but discoverable) bug in the code that's using CMFFormController.
In now way is this a bug in CMFFormController. At best it's a missing feature, and I'd argue it'd be a mis-feature.
Rolling back the transaction seems drastic. In some cases, you may even want to save something even if validation fails.
If you need to save something even if the validation fails at a later point, you can do a full commit at anytime.
Doing a full premature commit is bad. Something later (outside the control of your cpy script) could fail, in which case you do want something rolled back.
The same is not true when trying to abort something that you don't know that will fail...
I don't think it's hard. Let's say you set up a chain like this:
+---(success)-->[save script] --[page template]-->[validator]--+ +---(failure)-->[abort/error page]
The validator is in the chain explicitly. You may not know what in the validator exactly failed, but you *do* know that something failed, and you can react accordingly.
It's not hard to write form actions so that nothing is saved.
With the current Archetypes/CMFFormController integration it is impossible... :-/
How so?
If that's what this is all about, the Archetypes base_edit chains (which are insane), then that's an issue we should fix there, not something we should steamroll into CMFFormController just because that's easier.
My particular use case is the following:
- There's an AT content-type, and its schema has a reference field
- This field uses a special widget (UploadReferenceWidget) that allows you upload a file, creating a new File in ZODB *and* reference that File after its creation
- What happens now is that when the validation of any other field fails, I have no chance to abort the creation of that File
You could have an on-failed validator that did an explicit rollback?
Of course, that chain is not sane. There should be a pre-write validator that checks the whole Archetype, and only then should something be saved. In fact, I thought that's how it worked for other fields. Perhaps it's a deficiency in this particular widget's implementation?
I'm talking specifically about ZODB here, but the same would apply for RDB and file system changes. Again, if the validation fails, I would expect that *no* persistent changes remains.
I'm not sure that's a valid expectation 100% of the time, for all kinds of validators, for all use cases where CMFFormController is currently used. See my reply to Alan as well.
The fix could be done in Archetypes, but 'form processing' is a more general concept, and thus I would say that CMFFormController is the best place to do it.
I disagree. This is a case of AT not using the form controller correctly, or of your widget making wrong assumptions. In either case, something as drastic as a full transaction abort belongs there not in a general (and stable/old) framework.
And last, but not least, the proposed fix has tests and none of the existing CMFPlone, Archetypes, ATContentTypes, CMFFormController, CMFEditons, ..., tests fails after applying it... ;-)
That's not a good measure, unfortunately. All that means it that most (all) of the tested usages of CMFFormController use sensical (obvious) chains whereby you don't write until after the validator is complete.
Think of it differently - you don't get a transaction abort if a formlib validator or zope.interface invariant fails. That'd be crazy too. ;)
Martin
-- Author of `Professional Plone Development`, a book for developers who want to work with Plone. See http://martinaspeli.net/plone-book
------------------------------------------------------------------------- This SF.net email is sponsored by: Splunk Inc. Still grepping through log files to find problems? Stop. Now Search log events and configuration files using AJAX and a browser. Download your FREE copy of Splunk now >> http://get.splunk.com/







