On Aug 2, 2006, at 1:07 AM, Kevin Horn wrote:
> After upgrading to TG 0.9a8, I get teh following error for each of
> several widgets.WidgetsList subclasses.
>
> ValueError: No validator specified and couldn't guess one. I cannot
> work properly without it
>
> This appears to crop up for every instance of a SingleSelectField
> widget that I have in my application. If I throw in a dummy
> validator such as:
>
> company_id = widgets.SingleSelectField("company_id",
> label="Company",
> options=Company.build_list
> ('company_name'),
> validator= validators.NotEmpty() )
>
> ...the error disappears. Obviously, whatever code is trying to
> guess the appropriate validator is not getting the job done in my
> case.
What output does "Company.build_list('company_name')" produce? As
long as it's a list of tuples like [(0, "foo")] or [("bar, "bar")]
everithing should be fine... that is, and int or string in the first
position of every tuple. Another possibility is that the list is
empty so the "guessing" cannot work.
My advice is to always provide a validator explicitly for
SelectionFields and don't rely on the guessing (my position on this
issue has been stated in a recent thread in this list).
> I previously did not specify any validators for these fields, but
> now it seems that a validator is required for them.
Really? The SelectionField has always needed a validator (guessed or
passed explicitly) IIRC, maybe the list returned by
"Company.build_list('company_name')" is now empty?
> Why is this and is there any way of controlling this behavior or
> turning it off? I usually define all of my validators at or near
> the end of my development process, and this is kinda cramping my
> style ATM :)
>
> Am I likely to run into this with any other widgets?
Nope, the only ultra-smart widgets are the SelectionFields ;)
>
> And while I'm asking questions, is there a list anywhere of the
> available validators in TG? Or should I just look in tg.validators?
TG has available all FormEncode's validators plus the ones you see at
tg.validators. One note, in case a FE validator is redefined in
tg.validators (like the Schema) use the one provided by TG (that is
"from turbogears import validators" not "from formencode import
validators") because it's for a good reason, bad things will happen
otherwise ;)
Alberto
P.S. Let's remove this guessing behaviour altogether... pleaaaase! :)
It's causing too much trouble in too little time already...
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"TurboGears" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at http://groups.google.com/group/turbogears
-~----------~----~----~----~------~----~------~--~---