[Zope-CMF] unable to catch isMemberIdAllowed error

Alan Runyan runyaga@runyaga.com
Fri, 24 Jan 2003 15:17:06 -0600


you should check and then raise an exception
how about:

if REQUEST['username'] in self.acl_users.getUserNames():
    raise 'DuplicateUsername'

and then you can catch 'DuplicateUsername' in your PythonScript
and display appropriate error.

~runyaga


----- Original Message ----- 
From: "Colin Leath" <cleath@j9k.org>
To: <zope-cmf@zope.org>
Sent: Friday, January 24, 2003 3:06 PM
Subject: [Zope-CMF] unable to catch isMemberIdAllowed error


> The following code added to register.py is not having any effect:
> 
>      try:
>         portal_registration.addMember(REQUEST['username'], password,
> properties=REQUEST)
>     except:
>         failMessage='The login ndame you selected is already in use or is
> not valid. Please choose another.'
> 
> 
> the following does not have any effect either:
>     if portal_registration.isMemberIdAllowed(REQUEST['username']):
> 
> ---
> in short,
> when a registrant enters a username already in use I want to have a nice
> error message rather then have them dumped into an error screen.
> 
> 
> 
> BTW, here's my code for dealing with the case sensitive user name issue.
> It seems that so many CMF developers have to deal with this issue that
> there might as well be some code in the base cmf that handles this for
> those of us who do not want 2 usernames (e.g. Sara and sara) to be
> possible.
> 
> if REQUEST['username'].lower() <> REQUEST['username']:
>     failMessage = "Please use an all lowercase username. \n For example,
> use '%s' instead of '%s'." %
> (REQUEST['username'].lower(),REQUEST['username'])
>     REQUEST.set( 'error', failMessage )
>     return join_form( context, REQUEST, error=failMessage )
> 
> 
> Thanks for your help!
> Colin
> 
> 
> _______________________________________________
> Zope-CMF maillist  -  Zope-CMF@zope.org
> http://lists.zope.org/mailman/listinfo/zope-cmf
> 
> See http://collector.zope.org/CMF for bug reports and feature requests
>