error messages in Auth.change_password

40 views
Skip to first unread message

Sebastian E. Ovide

unread,
Jun 25, 2009, 8:35:36 AM6/25/09
to web...@googlegroups.com
Hi,

Using Auth.change_password I noticed that if the 2 password do not match web2py is giving the message "invalid expression!" and if the password is not valid the message is "value not in database!". Is it possible to change those strings with some more user friendly ones ?

thanks

Sebastian E. Ovide

mdipierro

unread,
Jun 25, 2009, 9:12:37 AM6/25/09
to web2py Web Framework
good point. these two strings come from the validators and do not have
customization. Will fix that.

On Jun 25, 7:35 am, "Sebastian E. Ovide" <sebastianov...@gmail.com>
wrote:

mdipierro

unread,
Jun 25, 2009, 11:25:36 AM6/25/09
to web2py Web Framework
Try the trunk and the following customizations:

auth.messages.invalid_email = 'Invalid email'
auth.messages.invalid_login = 'Invalid login'
auth.messages.invalid_user = 'Invalid user'
auth.messages.is_empty = "Cannot be empty"
auth.messages.mismatched_password = "Password fields don't
match"

Massimo

On Jun 25, 7:35 am, "Sebastian E. Ovide" <sebastianov...@gmail.com>
wrote:

Sebastian E. Ovide

unread,
Jun 26, 2009, 8:03:28 AM6/26/09
to web...@googlegroups.com
cool !   is it part of 1.63.4 ?

another question : is it possible to customize "change password" screen in the way to add a "cancel" button and/or another link such as "return home" ?

Fran

unread,
Jun 26, 2009, 8:52:01 AM6/26/09
to web2py Web Framework
On Jun 26, 1:03 pm, "Sebastian E. Ovide" <sebastianov...@gmail.com>
wrote:
> cool !   is it part of 1.63.4 ?

No - it was done in r959:
http://bazaar.launchpad.net/~mdipierro/web2py/devel/revision/959

1.64.4 is r957
https://code.launchpad.net/~mdipierro/web2py/devel

> another question : is it possible to customize "change password" screen in
> the way to add a "cancel" button

This may help: http://groups.google.com/group/web2py/browse_thread/thread/29aff17c10057932

> and/or another link such as "return home" ?

Add to your view:
A(T(''Return Home'), _href=URL(r=request, c='default'))

F

sebasti...@gmail.com

unread,
Jul 19, 2009, 2:28:59 PM7/19/09
to web2py-users
I have just tried and it is working fine for mismatched_password....

but in case the old password is wrong the message is still "value not
in database!"

Sebastian E. Ovide

unread,
Jul 19, 2009, 3:14:28 PM7/19/09
to web2py-users
just in case it could be useful:

Index: tools.py
===================================================================
--- tools.py    (revision 1140)
+++ tools.py    (working copy)
@@ -396,6 +396,7 @@
         self.messages.invalid_email = 'Invalid email'
         self.messages.invalid_login = 'Invalid login'
         self.messages.invalid_user = 'Invalid user'
+        self.messages.invalid_password = 'Invalid password'
         self.messages.is_empty = "Cannot be empty"
         self.messages.mismatched_password = "Password fields don't match"
         self.messages.verify_email = \
@@ -1173,7 +1174,8 @@
             label=self.messages.old_password,
             requires=validators(
                      self.settings.table_user[passfield].requires,
-                     IS_IN_DB(s, '%s.%s' % (usern, passfield)))),
+                     IS_IN_DB(s, '%s.%s' % (usern,passfield),
+                              error_message=self.messages.invalid_password))),
             sql.SQLField('new_password', 'password',
             label=self.messages.new_password,
             requires=self.settings.table_user[passfield].requires),


Sebastian E. Ovide


Sent from Dublin, Ireland

Hans Donner

unread,
Jul 19, 2009, 3:17:52 PM7/19/09
to web...@googlegroups.com
can you send it also as attachment?

Alex Fanjul

unread,
Jul 20, 2009, 8:00:17 AM7/20/09
to web...@googlegroups.com
Massimo, couldnt we use T function in such messages for internationalization?

With: auth.messages.submit_button = T('Enviar')
the system complain with:
TypeError: unsupported operand type(s) for %: 'lazyT' and 'Storage'

thanks
alex f


El 19/07/2009 20:28, sebastian...@gmail.com escribió:
auth.messages.invalid_email = 'Invalid email'
>         auth.messages.invalid_login = 'Invalid login'
>         auth.messages.invalid_user = 'Invalid user'
>         auth.messages.is_empty = "Cannot be empty"
>         auth.messages.mismatched_password = "Password fields don't
> match"
  

--
Alejandro Fanjul Fdez.
alex....@gmail.com
www.mhproject.org

Fran

unread,
Jul 20, 2009, 9:35:32 AM7/20/09
to web2py-users
On Jul 20, 1:00 pm, Alex Fanjul <alex.fan...@gmail.com> wrote:
> Massimo, couldnt we use T function in such messages for
> internationalization?
> With: auth.messages.submit_button = T('Enviar')
> the system complain with:
> TypeError:unsupported operand type(s)for%:'lazyT'and'Storage'

auth.messages should be of type Messages which supports
Internationalisation automatically (no need to use T())

Before that we had to subclass & pass T, but no longer :)

F

Sebastian E. Ovide

unread,
Jul 25, 2009, 10:26:55 AM7/25/09
to web2py-users
Hi Massimo,

just to remind you that it is not in the trunk yet.

thanks
--

mdipierro

unread,
Jul 25, 2009, 10:42:07 AM7/25/09
to web2py-users
Can you please email it to me?

Massimo

On Jul 19, 2:14 pm, "Sebastian E. Ovide" <sebastianov...@gmail.com>
wrote:
> sebastianovide+...@gmail.com<sebastianovide%2B...@gmail.com>

Sebastian E. Ovide

unread,
Jul 25, 2009, 11:47:44 AM7/25/09
to web...@googlegroups.com
eccolo
--
patch.txt

mdipierro

unread,
Jul 25, 2009, 7:58:22 PM7/25/09
to web2py-users
thank you

On Jul 25, 10:47 am, "Sebastian E. Ovide" <sebastianov...@gmail.com>
wrote:
> > sebastianovide%2B...@gmail.com <sebastianovide%252B...@gmail.com>>
>  patch.txt
> 3KViewDownload
Reply all
Reply to author
Forward
0 new messages