Can't use FieldSet with only CheckBoxes

17 views
Skip to first unread message

Felix Schwarz

unread,
Feb 7, 2012, 5:28:29 AM2/7/12
to toscawidge...@googlegroups.com
Hi,

after a longer debugging session I found out that you can't use a FieldSet
which only contains CheckBoxes (see attached example). If none of the boxes is
checked, the validation generation an error because the 'fieldset' is empty.

I think the reason is in tw.forms.core (generate_schema). A new schema is
generated but thanks to FormEncode's defaults (Schema is a standard
FancyValidator and implements a bad empty-ness check) it'll not recurse to
it's children when encountering an 'empty' value.

I'm not entirely sure what the best fix is here (I got so frustrated with
formencode's weirdness that I wrote my own validation long ago) but I think
the problem should be obvious.

fs

empty_form.py

Paul Johnston

unread,
Feb 9, 2012, 5:03:40 AM2/9/12
to toscawidge...@googlegroups.com
Felix,

There probably is a kludge to make this work, but really it's this kind of confusion that caused me to move away from FormEncode with tw2. Suggest you look at moving your app to tw2.

Paul



fs

--
You received this message because you are subscribed to the Google Groups "ToscaWidgets-discuss" group.
To post to this group, send email to toscawidge...@googlegroups.com.
To unsubscribe from this group, send email to toscawidgets-dis...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/toscawidgets-discuss?hl=en.


Felix Schwarz

unread,
Feb 9, 2012, 5:11:58 AM2/9/12
to toscawidge...@googlegroups.com
Hi Paul,

Am 09.02.2012 11:03, schrieb Paul Johnston:
> There probably is a kludge to make this work, but really it's this kind of
> confusion that caused me to move away from FormEncode with tw2.

What do you use instead of FormEncode?
(I found so many strange cases in FormEncode two years ago that I wrote my own
validation library [1])

> Suggest you look at moving your app to tw2.

Let's see. MediaCore (www.mediacorecommunity.org) is a pretty big project and
changing all the forms is a pretty big project which doesn't add too much user
value.

Also I have to say that I found ToscaWidgets (1) very hard to debug because of
the (excessive) inheritance chains which often only add an attribute or so.
Also the lack of documentation was a pretty big blocker for me (how do I
customize it, write custom form templates etc). Just skimming over the tw2
docs, looks like there are some improvements in this area.

cheers
Felix

[1] https://www.schwarz.eu/opensource/projects/pycerberus

Paul Johnston

unread,
Feb 9, 2012, 5:18:57 AM2/9/12
to toscawidge...@googlegroups.com
Hi,

What do you use instead of FormEncode?
(I found so many strange cases in FormEncode two years ago that I wrote my own
validation library [1])

Rolled my own validation library. I didn't know about yours at the time.

For validating individual fields, it's easy enough for TW to use an external validation library, be it FormEncode, yours, or whatever. I think the problems comes with repeaters and containers. TW1 had extensive (and buggy) code to keep the FormEncode schema in sync with the widget hierarchy. Because TW2 uses a built-in validation library, it side-steps this problem entirely - validation works directly off the widget hierarchy. All the other widget libraries (EasyWidgets, Django, etc.) all seem to take the same approach.

Let's see. MediaCore (www.mediacorecommunity.org) is a pretty big project and
changing all the forms is a pretty big project which doesn't add too much user
value.

Do you define a lot of your own widgets? If you just use tw.forms, moving to tw2 should be pretty easy. If you define your own widgets though, it's harder.

Paul


Reply all
Reply to author
Forward
0 new messages