On Mon, May 4, 2009 at 9:54 AM, Vidul Petrov <[email protected]> wrote:

>
> The issue is that different validators are required for different
> actions:


That's ok - since a thread lives only for the time of a request, this is
somewhat simple:

Since this does form validation, you can change this dynamically,
programmatically - probably close to where the need for it is...

>
>
> # in retrieve_password
> auth.table_user.email.requires has list with "IS_IN_DB" validator


Then put this statement in your retrieve_password()

>
>
> # in register
> auth.table_user.email.requires has list with "IS_NOT_IN_DB" validator


same - put this in your register() function...

Since a request will be one function - you do not need to worry about
"resetting" to default validator.
If you want, you can set a default, most used validator in your models file,
and change it in above functions when needed.

Make sense?

>
>
>
> On May 4, 5:27 pm, mdipierro <[email protected]> wrote:
> > Not sure I understand the issue.
> >
> > You can override tools validators in your models.
> >
> > auth=Auth(....)
> > auth.define_table()
> > auth.table_user.fiest_name.requires=IS_NOT_EMPTY(error_message=T('fill
> > it up!'))
> >
> > On May 4, 9:14 am, Vidul Petrov <[email protected]> wrote:
> >
> >
> >
> > > Thank you, guruyaya.
> >
> > > The problem is that these validators are called in tools.py and it
> > > does not allow T object usage.
> >
> > > On May 4, 4:49 pm, guruyaya <[email protected]> wrote:
> >
> > > > Sure. You can just go like this
> > > > requires=IS_EMAIL(error_message=T("Must be a vaild email"))
> > > > You need to do this to every validator you have.
> > > > (I didn't write the full syntax, but I'm quite sure you understand
> it.
> > > > Oh, and I'm not home, so it's not really tested, but I recall this is
> > > > the syntax).
> >
> > > > On May 4, 4:28 pm, Vidul Petrov <[email protected]> wrote:
> >
> > > > > Is translation of error_message attribute in validators.py
> possible?
> >
> > > > > The reason for this is that not all "error_message"s (imho) can be
> > > > > customized, for example in methods like retrieve_password and
> login.
> >
> > > > > Thank you for the help.
> >
>

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"web2py Web Framework" 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/web2py?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to