Proper ZCML tree for Zope 2.10
------------------------------
:Author: Philipp von Weitershausen, philikon@philikon.de
:Status: IsDraftProposal
Current situation
-----------------
Currently, ZCML initialization takes place as follows:
1. Zope initializes, among others, the Five product by calling
``Products.Five.initialize``::
def initialize(context):
zcml.load_site()
2. ``Products.Five.zcml.load_site`` checks whether
``$INSTANCE/etc/site.zcml`` exists. If not, it will fall back to
``Products/Five/skel/site.zcml`` which will be the case most of the
time because many Zope 2 developers, even though they might use
Five features, do not bother to copy the ``skel`` directory below
Five to their instance home.
3. As the first thing it does, ``site.zcml`` includes
``Products/Five/configure.zcml``::
This way, all directive handlers other than the basic ones are
registered as well as all the essential and not-so-essential
components that Five registers.
4. ``site.zcml`` then goes on including Zope 3-style package includes::
In the ``Products/Five/skel`` directory, ``package-includes`` is
empty. But when the ``skel`` directory is copied to the instance
home, it can serve as a place to put ZCML slugs, just like in Zope
3 instances.
5. Finally, ``site.zcml`` ends with including product configuration::
This will automatically find all installed products and search in
them for ``configure.zcml`` files and ``overrides.zcml`` files,
respectively. If these files exist, they are loaded. The Five
product's configuration is not loaded again as ZCML won't load any
files twice.
Summary:
I) The initialization of the Five product takes care of starting the
ZCML configuration tree.
II) Products can simply be dropped in and their ZCML configuration is
picked up automatically. This corresponds to the product
deployment scheme Zope 2 developers are used to.
III) Other Python packages need to be explicitly included by a ZCML
slug. This corresponds to the Zope 3 scheme of deploying
packages.
Problem
-------
Only point I) from above is the problem. In fact, this proposal does
not question the practice of points II) and III).
Five 1.2 for the first time introduced ZCML that is not about Five
anymore but about the Zope 2 core (mostly the OFS package). These
ZCML declarations should really be in the packages they are about, not
in Five.
Proposal
--------
This proposal is NOT about changing the automatic configuration of
Products.
XXX
zopeschema.xml
Zope2.App.startup:
zope.app.appsetup.config(options.site_definition, features=features)
probably more like Products.Five.zcml.load_site()
notify(zope.app.appsetup.interfaces.DatabaseOpened(DB))
Risks
-----
XXX