validators.All
"Brian Bird" <Brian.Bird-CJf51mobArP9X/uwxB7CKgC/[email protected]> Tue, 24 Jun 2008 15:41:20 +0100
| Newsgroups | gmane.comp.python.formencode |
|---|---|
| Message-ID | <[email protected]> |
I've just started using TurboGears which uses formencode a lot - and I
came across some unexpected behaviour with the validators.All compound
validator.
I would have expected the following validators to be equivalent:
>>> print validators.String(if_empty="EMPTY").to_python("")
EMPTY
>>> print
validators.All(validators.String(if_empty="EMPTY")).to_python("")
None
>>>
There also seems to be a similar problem with empty_value
The documentation states validators.All will iterate over all it's
validators, but for empty cases it seems to use it's own logic (because
it inherits FancyValidator)
This seems to be a similar problem I've just found on the discussion
list:
http://sourceforge.net/mailarchive/forum.php?thread_name=6e9196d20801281
347k1e5fe70bsd2ba768aa6de898e%40mail.gmail.com&forum_name=formencode-dis
cuss
That deals with not_empty and concludes there may be "unnecessary
cleverness" in inheriting the not_empty from it's children, but not the
messages.
Would it not be better to ensure validators.All will always iterate over
it's children and not inherit any of the if_empty,not_empty,empty_value
behaviours?
Brian
-------------------------------------------------------------------------
Check out the new SourceForge.net Marketplace.
It's the best place to buy or sell services for
just about anything Open Source.
http://sourceforge.net/services/buy/index.php
_______________________________________________
FormEncode-discuss mailing list
FormEncode-discuss-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f@public.gmane.org
https://lists.sourceforge.net/lists/listinfo/formencode-discuss