quick search:
advanced search

Adding users using your own forms

Submitted by: mirage
Last Edited: 2001-07-27

Category: Python(Script)

Average rating is: 3.2 out of 5 (5 ratings)

If you want to add users to the acl_users default user folder, you can do so by using a form and a _very simple_ python script. In this trivial example, the form is propably more complex than the python script itself!

Source (Text):
#the form that the user fills in to add themselves to the database
#a simple example:

<form action="add_user" method="post">

Name:  <input type="text" name="name"><br>
Password: <input type="password" name="password" ><br>
Confirm password: <input type="password" name="confirm"><br>

#to cycle through all available roles and add them to a selection box
#do the following:

User roles: <br>
  <select name="roles:list" size="5" multiple>
  <dtml-in valid_roles>
  <dtml-if expr="_vars['sequence-item'] != 'Anonymous'">
  <dtml-if expr="_vars['sequence-item'] != 'Shared'">
  <option value="<dtml-var sequence-item html_quote>"><dtml-var
  </dtml-in valid_roles>
<input type="submit" name="submit" value="Add" />

#that's it with the form! now for the python script
#the python script which your form calls

context.acl_users.manage_users('Add', context.REQUEST)
return "User added!"

#note: you must have an acl_users folder in the same directory as the form and the python script.

#Note: there is an optional property for a user, the domain field.
#to add it, just add it to the form as follows:

Domains: <input type="text" name="domains:tokens" size="30" value="" />


thanks! by ruckc - 2001-07-25
I have been looking for this for a long while now.

Looks Great, BUT it doesnt seem to work. by lanman - 2001-07-27
I keep getting:

Zope Error
Zope has encountered an error while publishing this resource.

Error Type: SyntaxError
Error Value: Line 2: "_vars" is an invalid variable name because it starts with "_"


Troubleshooting Suggestions

The URL may be incorrect.
The parameters passed to this resource may be incorrect.
A resource that this resource relies on may be encountering an error.
For more detailed information about the error, please refer to the HTML source for this page.

If the error persists please contact the site maintainer. Thank you for your patience.


So, whats wrong with this ?