[Zope] How can I check a user_acl folder to see if a user already exists?

Danny William Adair danny@adair.net
Tue, 30 Oct 2001 21:44:35 +1300


How about this one?

----------------------------------------------------
if context.acl_users.getUser(request.form['Username']):
  # user exists
else:
  # user does not exist
----------------------------------------------------

getUser() returns a user object, None ( -> false ) if the user does not exist.

This way you don't retrieve the whole user list, might be many.

hth,
Danny

On Tuesday 30 October 2001 18:14, you wrote:
> basically, you'll want to do something along the lines of:
>
> request = context.REQUEST
> response = request.RESPONSE
> if request.form['Username'] in context.acl_users.getUserNames():
>    response.redirect('/UserAlreadyExists.html')
> else:
>    # add user here
>
> On Mon, 2001-10-29 at 12:11, Rob Foster wrote:
> > Here's the setup:
> >
> > I'm trying to add users to my site by having them fill out a form with
> > the following fields:
> >
> > Username
> > Password
> > Confirm (password confirmation)
> >
> > I want the form to post to a python script that will check the folder
> > and do a redirect to another document depending on what happens... I
> > don't know Python that well. I've tried doing it in dtml with no results.
> >
> > Can someone help me with a little example code or at least point me to a
> > product that does this? Thanks in advance. -Rob
> >
> >
> > _______________________________________________
> > Zope maillist  -  Zope@zope.org
> > http://lists.zope.org/mailman/listinfo/zope
> > **   No cross posts or HTML encoding!  **
> > (Related lists -
> >  http://lists.zope.org/mailman/listinfo/zope-announce
> >  http://lists.zope.org/mailman/listinfo/zope-dev )