37 messages in net.sourceforge.lists.plone-developersRe: CMFFormController should abort th...
FromSent OnAttachments
Dorneles TreméaNov 9, 2007 3:17 pm 
Philipp von WeitershausenNov 10, 2007 7:07 am 
Dorneles TreméaNov 10, 2007 7:58 am 
Wichert AkkermanNov 10, 2007 12:22 pm 
Martin AspeliNov 10, 2007 2:12 pm 
Wichert AkkermanNov 10, 2007 4:20 pm 
Philipp von WeitershausenNov 11, 2007 1:32 am 
Dorneles TreméaNov 11, 2007 5:19 pm 
Alan RunyanNov 11, 2007 5:20 pm 
Martin AspeliNov 11, 2007 5:44 pm 
Martin AspeliNov 11, 2007 5:51 pm 
Wichert AkkermanNov 12, 2007 4:37 am 
Sidnei da SilvaNov 12, 2007 4:43 am 
Daniel KraftNov 12, 2007 5:40 am 
Martin AspeliNov 12, 2007 5:52 am 
Dorneles TreméaNov 12, 2007 9:35 am 
Wichert AkkermanNov 12, 2007 9:56 am 
Martin AspeliNov 12, 2007 9:59 am 
Martin AspeliNov 12, 2007 10:00 am 
Dorneles TreméaNov 12, 2007 10:56 am 
Martin AspeliNov 12, 2007 11:14 am 
Martin AspeliNov 12, 2007 11:21 am 
Wichert AkkermanNov 12, 2007 11:36 am 
Martin AspeliNov 12, 2007 11:41 am 
Sidnei da SilvaNov 12, 2007 11:47 am 
Martin AspeliNov 12, 2007 12:04 pm 
Dorneles TreméaNov 12, 2007 12:28 pm 
Dorneles TreméaNov 12, 2007 12:34 pm 
Dorneles TreméaNov 12, 2007 1:29 pm 
Wichert AkkermanNov 12, 2007 1:32 pm 
Martin AspeliNov 12, 2007 1:41 pm 
Dorneles TreméaNov 12, 2007 1:44 pm 
Martin AspeliNov 12, 2007 1:46 pm 
Wichert AkkermanNov 12, 2007 1:46 pm 
Martin AspeliNov 12, 2007 1:47 pm 
Dorneles TreméaNov 12, 2007 5:11 pm 
Daniel NouriNov 13, 2007 4:14 am 
Actions with this message:
Paste this link in email or IM:
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 failsActions...
From:Dorneles Treméa (deo-@public.gmane.org)
Date:Nov 12, 2007 5:11:18 pm
List:net.sourceforge.lists.plone-developers

Hey,

It would be great if Archetypes pass an additional keyword to the widget.process_form() call saying that it's in the 'validating' or the 'processing' phase... otherwise we'll need to mess with the REQUEST and set some kind of flag...

any objection to the following change?

Index: Archetypes/Schema/__init__.py =================================================================== --- Archetypes/Schema/__init__.py (revision 8902) +++ Archetypes/Schema/__init__.py (working copy) @@ -582,8 +582,14 @@ widget = field.widget

if form: - result = widget.process_form(instance, field, form, - empty_marker=_marker) + try: + result = widget.process_form(instance, field, form, + empty_marker=_marker, + validating=True) + except TypeError: + # Support for old-style process_form methods + result = widget.process_form(instance, field, form, + empty_marker=_marker) else: result = None if result is None or result is _marker:

I've an objection! :-P

The widget.process_form() method is called multiple times, in the following order:

1) validate_base.vpy initially calls it from Schema.BasicSchema.validate()

2) Then one subsequent call is made for each registered validator for that particular field. Each field has at least one defined validator: ('isEmpty', V_SUFFICIENT)

3) Then one call is made from the BaseObject.processForm() method. This is the only place where the returned data is forwarded to the storage layer. This ends the validate_base.vpy calls.

4) Then enters the calls from the validate_integrity.cpy script. Again, first a call from Schema.BasicSchema.validate()

5) And then another call for each registered validator...

Interesting, huh? At least 5 times per field.

So, it would be better to do the other way round: assume that 'validating' is True and then passing False when called by BaseObject.processForm() method:

http://dev.plone.org/archetypes/ticket/760

This way we avoid breaking all existing validators.

Nouri, do I have your bless? :-)

--

_______________________________________________________

Dorneles Treméa · Developer, Jarn · www.jarn.com

Plone Solutions, Development, Hosting and Support

_______________________________________________________

Plone Solutions is now known as Jarn www.jarn.com/name-change