[Zope] how to programmatically control zope?

Paul Winkler pw_lists at slinkp.com
Fri Sep 16 11:28:28 EDT 2005


> akonsu wrote:
>> hello, would someone please point me to the right direction? what is
>> the preferred way to control a zope server programmatically? i need to
>> be able to administer my zope instance from a script. add users,
>> change permissions, create new sites, add objects to the sites. there
>> is webdav, xml-rpc, what else?

Here's an overview of web-based techniques that might be useful...
http://www.plope.com/Books/2_7Edition/ScriptingZope.stx#1-9
but I prefer doing as Bruno does:

> Interactively control/inspect/play with the server:
> <ZOPE_INSTANCE>/bin/zopectl debug
>
> Run a script on the server:
> <ZOPE_INSTANCE>/bin/zopectl run <myscript.py> [args...]

yep, I like working that way, and Bruno's introduction is excellent.
One clarification however:

> 1/ You can't run zopectl debug or zopectl run while you instance is
> running (as it locks the ZODB). The solution here is to set up a zeo
> instance (this is really easy), and have 2 zope instances, one serving
> the web requests, the other being used for debug/run

That's a bit misleading.
With ZEO, you don't need two full instances (by which i mean directories
containing their own etc, bin, var, and log subdirectories).
You can run the Zeo server AND one Zope server out of a single instance
home at the same time; and since your zopectl scripts won't normally
involve starting up on a tcp/ip port, you can run those from the same
instance too.  I do it all the time.

Example (for any unix-like environment):

cd MyInstanceHome
../bin/zeoctl start
# ZEO is now running in the background.
../bin/zopectl start
# Zope is now running in the background, connected to ZEO.
../bin/zopectl run myscript.py &
# I'm now running a script via zopectl in the background.
# This can run at the same time as Zope, because it runs as
# a separate process and talks to Zeo, which accepts many clients
# at once.
../bin/zopectl debug
# I am now interacting with ZEO via a python shell.
# Again, this is a separate process connecting to Zeo so I can do this
# as many times as I want simultaneously.

It's only when you want to run multiple Zope server processes
on multiple ports simultaneously that you actually need to set up multiple
instance homes.

-PW





More information about the Zope mailing list