This article shows how to add another Zope Manager to top acl_users folder. Under Linux you can use zopectl but this desn’t work on Windows.
Some time ago it was possible to add Manager to Zope instance using inituser file. I’m not sure when or why this functionality was abandoned. But currently it is possible only using zopectl adduser command. There is a little problem on Windows. This script doesn’t work on this system. I’ve looked inside code of Zope2/Startup/zopectl.py and it is really focused on Linux. So I had to find my own solution.
Copy those 2 files described below to your /bin directory and run:
If user does not exist it will be added. Otherwise you will see message or error. It was tested on Zope 2.9
Shell script add_user.bat
First part is a shell script – .bat file. It sets some variables (copied from runzope.bat). But variables defined in runzope.bat were not enough. I was getting errors until I’ve defined ZOPE_CONFIG. This environment variable is used during startup to find config file.
Python script add_user.py
And here is Python script that adds user. The most important fragment is copied from method do_adduser inside Zope2/Startup/zopectl.py. Then I’ve added few details like reading data from command line parameters, checking if user exists, nice messages.
if len (sys.argv) 3 :
print “Bad syntax: add_user.py
LOGIN=sys.argv[ 1 ]
PASSWORD=sys.argv[ 2 ]
#Remove all arguments otherwise Zope.app() raise error
del sys.argv[ 2 ]
del sys.argv[ 1 ]
app = Zope2.app()
acl_users = app.acl_users
if not acl_users.getUser(LOGIN):
acl_users._doAddUser(LOGIN,PASSWORD, [ ‘Manager’ ], )
print “User ‘%s’ added” %LOGIN
print “User ‘%s’ already exists, not added” %LOGIN
print “User ‘%s’ NOT added” %LOGIN
print “ERROR: %s-%s ” %(sys.exc_info()[ 0 ],sys.exc_info()[ 1 ])
just one to add one user with manager role
Could you tell me how to add one user manager into zope site cause i have just taken over a zope system but i don’t have any account to manage it.