[Zope] Record a new user with python script

Dieter Maurer dieter@handshake.de
Thu, 30 Aug 2001 22:47:03 +0200 (CEST)


Gilles Lenfant writes:
 > I got a "join" page where a new user creates its nick/password.
 > A python script controls this and records if successful in acl_users of the
 > current folder with "inscrit" local role.
 > But there seems to be a problem with the password... because I can't read
 > the page protected for the "inscrit" role using the newly created user.
 > It works again when changing the password in the ZMI.
 > 
 > Here's my code...
 > 
 > # start
 > form = context.REQUEST.form
 > context.REQUEST.set('name', form['newusername'])
 > context.REQUEST.set('password', form['newpassword'])
 > context.REQUEST.set('confirm', form['cnewpassword'])
 > context.REQUEST.set('roles', ['inscrit'])
 > context.acl_users.manage_users(submit='Add', REQUEST=context.REQUEST)
 > # go to page where only 'inscrit' and 'Manager/Owner' users have view
 > permission
 > return context.apres_id(context, context.REQUEST)

It this script executed by the user that just tries to join?
Probably, as this is natural for a "join" page....

Then your problem is easy.

  That you added a new user does not change the user currently
  executing.
  You may need a "RESPONSE.redirect" to give your new
  user a chance to login.


Dieter