Kevin Dangoor wrote:
> On 4/7/06, Jorge Godoy <[EMAIL PROTECTED]> wrote:
> >
> > "Michele Cella" <[EMAIL PROTECTED]> writes:
> >
> > > TextField(validator=Int()) -> field not required
> > > TextField(validator=Int(), is_required=True) -> field required
> > > TextField(validator=Int(not_empty=True)) -> field_required
> > > TextField(validator=Int(not_empty=True), is_required=False) ->
> > > field_required
> > >
> > > Opinions on this? I don't like the last one but I can't see anything
> > > better as a solution.
> >
> > I'd throw an exception on the last case. It is never good to make
> > assumptions
> > on what the developer wanted to do. Something like what the error_handler
> > does for ambiguous handlers.
>
> +1
I don't like this solution that much anyway, I've prepared a patch for
FE to manage not_empty in the right way, let's see what Ian thinks (I
emailed him), then we could do this in a easier and cleaner way. ;-)
The idea is to provide a validator_args (better name anyone?) parameter
that let's you specify additional args without providing a new
validator:
TextField(validator_args={'not_empty':True})
this is more coherent IMHO, and let's us define a clear policy:
TextField(validator=Int(not_empty=False),
validator_args={'not_empty':True})
if the parameter is already specified in the validator this takes the
precedence, moreover the above case will (hopefully) never happen since
if you are providing a new validator you will not use validator_args
(unless your are crazy and want to be not DRY). ;-)
Ciao
Michele
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"TurboGears Trunk" 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-trunk
-~----------~----~----~----~------~----~------~--~---