#195: Support product dependencies
- Contents
- Proposed by
- Wichert Akkerman
- Proposal type
- Architecture
- Assigned to release
- State
- completed
Definitions
Motivation
At the moment dependencies between products are not handled very well. Dependencies are often only listed in an INSTALL.txt file, which is unfortunately all too often not read. Dependencies need to be installed manually by users, or a product has to have python code which installs its dependencies. This is tedious and error-prone work.
Assumptions
Proposal
Upgrade to the next GenericSetup release and modify CMFQuickInstaller to automatically mark products as installed when their profile is loaded.
The upcoming GenericSetup release has several useful features: zcml step registration, even support and dependency handling.
ZCML step registration allows you to register GenericSetup import and export steps using zcml instead of import_steps.xml and export_steps.xml files in GenericSetup profiles. This has two clear advantages: whenever you install a product in your instance all its import and exports steps are immediately available - you no longer have to load a profile which registers them first. This makes the step registration a lot more predictable. The other advantage is that removing your product will also mean its steps are no longer available. So no more broken old steps that keep collecting in your portal_setup. The zcml is quite simple and looks like this:
<configure
xmlns:genericsetup="http://namespaces.zope.org/genericsetup"
i18n_domain="genericsetup">
<genericsetup:importStep
name="name"
title="title"
description="description"
handler="Products.GenericSetup.tests.test_zcml.dummy_importstep_handler">
<depends name="something.else"/>
</genericsetup:importStep>
</configure>
one thing that you may notice is that there no longer is a version parameter for import steps. Since this was never used that has been deprecated and support for it will eventually be removed.
The other change is support for dependencies in a profile. A GenericSetup profile can include a metadata.xml file which contains some useful information about that profile. It looks like this:
<metadata>
<description>This is the profile description</description>
<version>1.0</version>
<dependencies>
<dependency>profile-Products.foo:default</dependency>
<dependency>profile-Products.bar:default</dependency>
</dependencies>
</metadata>
the version number is used when handling GenericSetup upgrade steps and has been around for a while (it ships with Plone 3). (On a side note: the fallback logic that will use the version.txt of your product has been marked as deprecated as well - mixing configuration versions with product release versions was a bad idea.) The dependency elements are new: you can use those to tell GenericSetup that when it imports that profile it should first do an import on those two contexts. This will work recursively, with a simple check to seen it will not run into dependency loops. This feature basically allows you to declare dependencies between different products - GenericSetup will take care of handling your dependencies.
CMFQuickInstallerTool can use the new set of events from GenericSetup to detect succesfull full profile imports and automatically mark products as installed if their profile has been imported. If you use this you will see all dependencies of your product automatically being installed, including all the usual snapshotting of context CMFQuickInstallerTool does which allows it to easily do an uninstall.
Implementation
Deliverables
CMFQuickInstaller and GenericSetup releases will be needed.
Risks
There is no risk involved in these changes. The only noticable change for existing products is that GenericSetup will now produce a deprecation warning for products with a GenericSetup profile which does not contain a metadata.xml with version information.
One possible problem is that GenericSetup will only warn if a dependency is missing. This means that if a required product has not downloaded and installed in the instance by the user he will not get a proper error message. This problem does not exist for products shipped as eggs: eggs allow the developer to specify dependencies which will be enforced by tools such as buildout and setuptools/easy_install.
Progress log
The GenericSetup changes have been implemented and merged to trunk. Both CMF and Plone trunk depend on the dependency handling logic now.
The CMFQuickInstaller changes have been implemented on a branch and are waiting review and merge from Hanno.
Participants
Framework team vote