also join form/zptstylesheet bug Re: [Zope-CMF] unable to catch isMemberIdAllowed error

Colin Leath cleath@j9k.org
Fri, 24 Jan 2003 17:20:37 -0500 (EST)


I figured out my problem!

clearly I do not understand well the code in RegistrationTool.py..

the checking for isMemberIdAllowed
is occurring in testPropertiesValidity

not in addMember

so,  the following works nicely:

if not portal_registration.isMemberIdAllowed(username):
    failMessage='The login name you selected is already in use or is not
valid. Please choose another.'
    REQUEST.set( 'error', failMessage )
    return join_form( context, REQUEST, error=failMessage )

failMessage = portal_registration.testPropertiesValidity(REQUEST)
#as long as it is before ^^^



I see now that my problem was that I was looking at the
RegistrationTool.py in CMFCore
instead of CMFDefault.


thanks for your patience,

but I note also, like with the case sensitive username, this should
perhaps be default behavior... I know.. it is a Framework, not a System.




while I'm making noise, it appears to me that to get the error messages on
the join form to show up nice and pretty, I had to add the following to
my zptstylesheet:

.DesktopStatusBar {
    color: Red;
    background-color: White;
    font-family: Arial, Verdana, Helvetica, serif;
    font-style: italic;
    font-weight: bold;
    margin-top: 8pt;
    /*text-transform: lowercase;*/
    padding-left: 2pt;
}

#########that is in addition to what is in there by default (this has
probably been customized by me):


#DesktopStatusBar {
    color: Red;
    background-color: White;
    font-family: Arial, Verdana, Helvetica, serif;
    font-style: italic;
    font-weight: bold;
    margin-top: 8pt;
    /*text-transform: lowercase;*/
    padding-left: 2pt;
}



I'm assuming I should put that in the collector?

the question is, is it a stylesheet bug or a join form bug?

Colin




On Fri, 24 Jan 2003, runyaga@runyaga.com wrote:

> 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
> >>
>