[Zope] How to know if a user already exists?
Jens Vagelpohl
jens@zope.com
Fri, 17 Aug 2001 07:53:27 -0400
umh, this could spell trouble for many user folder implementations where=20=
retrieving the user contents requires more work, like database or=20
LDAP-lookups. the "getUserNames" or "getUsers" methods on those kinds of=20=
user folders should be used sparingly ;)
all you really need to do is to take the new user name and use it to =
call=20
getUser on the user folder. if the result is "None" there is no user of=20=
that name in the respective user folder. otherwise you get back a user=20=
object.
if self.acl_users.getUser( new_user_name ):
return 'Error: User Exists'
else:
self.acl_users._addUser( username, password, confirmpass, =
liste_role,=20
0 )
jens
On Friday, August 17, 2001, at 04:30 , Sylvain Boureliou wrote:
> Sorry for the last empty Re:
>
>
> Hi Juan
>
> You can try :
>
> confirmation =3D "ok"
>
> for x in self.acl_users.getUserNames():
> if (x=3D=3Dusername):
> confirmation=3D"error"
> break
>
> if confirmation=3D=3D'ok':
> =
self.acl_users._addUser(username,password,confirmpass,liste_role,
> 0)
>
>
> Sylvain
>
>
>
> -----Message d'origine-----
> De : zope-admin@zope.org [mailto:zope-admin@zope.org]De la part de =
Juan
> Garcia Garcia
> Envoy=E9 : vendredi 17 ao=FBt 2001 10:11
> =C0 : zope@zope.org
> Objet : [Zope] How to know if a user already exists?
>
>
> I have a form with two fields, one to write a login and the other for =
the
> password. When the anonymous user pushs the submit button I will =
create a
> new user with the id and password written. But I want to know, before
> doing this action, if the login already exists in the folder =
'acl_users'.
> I tried with the function 'has_key' but it didn't work. If anyone has =
do
> it before, please send me the answer.
>
> Thank you.
>
>
>
>
>
>
> _______________________________________________
> 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 )