Sorry,
found the solution.
Using this syntax works:
validator = validators.All(validators.NotEmpty(), CheckUsername(),
messages={'empty': 'Please insert a nickname'}))


On 22 Ago, 19:26, venomous <[EMAIL PROTECTED]> wrote:
> Hello,
> i can't find a solution and i'm going crazy.
> i have a field that check if a nickname is already in use, and also
> the field mst be filled.
> So i have a custom validator:
>
> class CheckUsername(validators.FancyValidator):
>     """
>     Check if the user_name is already in use
>     """
>     def _to_python(self, value, state):
>         user = User.by_user_name(value)
>         if user != None:
>             raise validators.Invalid(
>                 _('Sorry, this username is already in use'), value,
> state)
>         return value
>
> then a widgetlist with some fields:
>
> class UserRegister(widgets.WidgetsList):
>     """
>     Users Registration Form
>     """
>
>     user_name = widgets.TextField(label=_("Nickname"),
> help_text=_("Please pick a nickname"),
>         validator =
> validators.All(validators.NotEmpty(messages={'empty': _('Please insert
> your username')}),
>             CheckUsername()))
>     #other fields below........
>
> and the form:
>
> form_users_register= PolishForm(
>     fields = UserRegister(),
>     validator = Schema(chained_validators=[FieldsMatch("password2",
>                      "password")]),
>     action = "newUser"
> )
>
> Now the problem is that i use _only_ the validator
> validators.NotEmpty() i get my empty error string (Please insert your
> username) but if use both validators with validators.All() when the
> field is empty i get the normal message "Please enter a value".
> I don't know if i'm missing something so any help is much appreciated.


--~--~---------~--~----~------------~-------~--~----~
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?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to