[Zope-Coders] New API for Zope configuration info
Fred L. Drake, Jr.
fred@zope.com
Mon, 10 Feb 2003 17:09:13 -0500
New API for Zope configuration info
===================================
The problem
-----------
Zope 2 code uses a handful of "widely-known" values for configuration,
as well as a host of less well known values. Several values are found
in environment variables and are only used by one portion of the
code. Others are used in several places, and are located in different
ways.
We'd like to clean this up in preparation for the work being done to
make Zope more readily managable. Part of this involves the effort
going into the "new-install-branch" code, and part of this is simply a
matter of making more consistent use of configuration values.
Our goal is to have a single way for the Python code that implements
Zope to get ahold of configuration information. Implementing this
will occur gradally, but I'd like to start by making some of the most
commonly used values available by a new API that will be used for all
configuration information in Zope 2.7.
In particular, I'd like to make the *_HOME values available by a
mechanism that will make sense even after the "new-install-branch"
changes have landed. This will allow Zope to not need to worry about
how the values for these variables were determined, but will keep them
readily available. These values are currently pulled from four
different places: the App.FindHomes module, the Globals module, the
built-ins namespace, where they are surgically inserted by
App.FindHomes on import, and even from environment variables in a few
places. The current approach to getting this information causes every
user of the information to be dependent on the order of imports, which
is generally quite fragile. This proposal attempts to avoid that
fragility.
The proposal
------------
I propose that App.FindHomes should be regarded as an implementation
detail, and that it not be used as the API use to get configuration
information. I also propose that Globals be handled in the same way.
Both will still be supported in Zope 2.7 (at least) to allow 3rd-party
products to continue working, but all code shipped with Zope will use
the new API.
A new module, App.config, will be introduced. It will contain the
function getConfiguration(), which will return an object with useful
attributes:
clienthome -- the same as CLIENT_HOME
instancehome -- the same as INSTANCE_HOME
softwarehome -- the same as SOFTWARE_HOME
zopehome -- the same as ZOPE_HOME
Additional attributes will be added as they make sense.
Please send comments to the zope-coders list.
-Fred
--
Fred L. Drake, Jr. <fred at zope.com>
PythonLabs at Zope Corporation