[Zope-CMF] unable to catch isMemberIdAllowed error
Colin Leath
cleath@j9k.org
Fri, 24 Jan 2003 16:06:10 -0500 (EST)
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