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 ])
There is always the easiest way – google 🙂 try: http://plope. com/Books/2_7Edition/Security. stx#3-31
Easier but not exactly
subtransactions are deprecated; instead of transaction. commit(1), use
transaction. savepoint(optimistic=True) in contexts where a subtransaction
abort will never occur, or sp=transaction. savepoint() if later rollback is
possible and then sp. rollback() instead of transaction. abort(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.
i just add some code into: ..\lib\python\Zope\App\startup. py
acl_users = app. acl_users
acl_users._doAddUser(‘nghia’,’password’, [‘Manager’], )
but it’s seem not working
Could you show me how to.
Thanks in advance
How to add manager
6. Start instance: ‘./zopectl start’