RequestForComments: Pythonic Zope Instance Manager
(prototype w/o working code, just interface)

News:

2003-09-09: Shane Hathaway make his first comment (well, not (yet) directly related), but worth looking it: [comments]

Abstract:

The idea behind this is create a standard interface to handle creation and management of Zope instances with pure python classes & code.

Extend this framework to be used by a GUI as a front-end on major OS (Win32, Linux) as a simplified interface to Zope.

 
Why?

On Win32 Zope distribution, from the time users download it until they start playing with it, takes a long time and a lot of mistakes due lack of KickStart (?) guides for the distro or the hackiesh nature of command line (that sometimes alienate a few users).

As a developer (forced to use Windows for video stuff), found sometimes repetitive and error-prone the use of cmdline for instance creating, manual editing of configuration files and a lot of things that must be taked into account before you jump to the ZMI (web-based management interface).

Even there exist products that encapsulate the handling of instances (ZopeController currently in use by Plone as PloneController) it didn't address very well the configuration of instances, maybe because the hackish nature of z2.py (included zope 2.6.x) command line switches and enviroment variables. Configure a instance even with *Controller need a lot of knowledge of z2.py cmdline switches and how configuration is handled.

With the arrival of Zope 2.7, a new way of handling instance was born, but still the learning curve for newcomers is cumerstone (mkzopeinstance, mkzeoinstance).

 
My Vision

At the time the user have downloaded and installed Zope, we should offer these users a simple way to configure for what they want to use zope, maybe with Wizards or expert mode but simpler in general lines.

Configure services (http,ftp,webdav), loggers (event.log, z2.log, debug.log) databases & mount-points (zodb, apedb, zeoclient) and simplified management/installation of products that follow a packaging standard.

Make these instances "per-user" instead of system-wide, so the playground used by a user couldn't be touched my other user on the same computer.

 
How this work? (or should)

Everything is based on a few classes.

Manager (proto): the one that encapsulates all the instances that belong to the current user and allow creation of new instances or addition of already made ones. provide the default reference to ZOPE_HOME and PYTHON executable to be used by the creation process of new instances.

Instance (proto): the objective INSTANCE_HOME representation, allow you query services, products, loggers and databases, add users, start/stop it, register service (PythonService) and get extended information of ZOPE_HOME and PYTHON used (could differ from instance to instance compared to Manager defaults). Allow you in a objective way modify the zope.conf file and the starting scripts of each instance.

Services, Products, Databases & Loggers classes don't exist (yet) ;).

A theorical example script:

from ZInstanceManager import *


# the next line will read the ZOPE_HOME & PYTHON paths from default section
myManager = Manager(configfilename="%USERPROFILE%\myzopes.cfg")

# print the default ZOPE_HOME
print myManager.ZOPE_HOME

# list the instances controlled by this manager (key,value from dict())
for key,instance in myManager.instances.items():
	print instance.name

# now list the ZOPE_HOME & PYTHON used by each instance
for key,item in myManager.instances.items():
	print item.name, item.ZOPE_HOME, item.PYTHON
	
# create a new instance (using default PYTHON but other ZOPE_HOME)
myzope123 = myManager.AddInstance(instancename='myzope123',
					INSTANCE_HOME=r'f:\sandbox\myzope123', 
					ZOPE_HOME=r'f:\binary\zope-2.7-cvs')

# print the version.txt of the zope used on the 'myzope123' instance
print myzope123.zopeVersion()

# save the manager configuration file with the newly created instance
myManager.save()

# query if exist a service 'myzope123' registered (win32 only)
if not myzope123.isServiceRegistered():
	myzope123.RegisterService()

# start service 'myzope123' (win32 only)
myzope123.StartService()

file myzopes.cfg before and after changes:

[defaults]
ZOPE_HOME = C:\Program Files\Zope-2.7.0-b1
PYTHON = C:\Python22\python.exe

[instances]
myplonetest = F:\SandBox\plonetest
APEtesting = T:\Luis\Zope\ape_test
z27zodbmounting = F:\ZopeInstances\2.7\multizodb


[defaults]
ZOPE_HOME = C:\Program Files\Zope-2.7.0-b1
PYTHON = C:\Python22\python.exe

[instances]
myplonetest = F:\SandBox\plonetest
APEtesting = T:\Luis\Zope\ape_test
z27zodbmounting = F:\ZopeInstances\2.7\multizodb
myzope123 = f:\sandbox\myzope123

 
Download

Click here to get the proto1.py file and check to comment on it.

Comments

Comments are welcome :)
Send them to luislavena at hotmail.com with subject: "RFC: ZInstanceManager" to avoid deletion by my spam handler.

There exists some detractors of the idea, but many win32 users and maybe others linux ones too (maybe the scripting capabilities to handle ISP Zope configuration?)

Copyright

Currently, no license model for the code in proto1.py, everything else (the css file used by this page) is stolen from py2exe project (liked the <pre></pre> style)
CSS: Copyright (C) 2001, 2002, 2003, Thomas Heller, Mark Hammond
Zope and the encircled Z are registered marks of Zope Corporation.