[Zope-CMF] Re: GenericSetup extension profile import step mis-feature

Wichert Akkerman wichert at wiggy.net
Tue Jul 31 04:02:51 EDT 2007


Previously Hanno Schlichting wrote:
> Martin Aspeli wrote:
> > Hi guys,
> > 
> > After a lot of "is-this-a-bug" type discussions with Rob and Wichert,
> > I've come to feel pretty strongly about the following:
> > 
> > When you load an extension profile for the first time in GS, it looks to
> > see if it has any import steps (in import_steps.xml) that are not
> > already "known". If so, it adds them to the import step registry and
> > then runs all steps in the registry.
> > 
> > Any time a profile (the same, or another one) is run subsequently, that
> > import step will be run too. In Rob's words, the import steps and the
> > profile that they came from (import_steps.xml-wise) get decoupled.
> > 
> > We normally don't mind too much, because steps are run in the context of
> > a particular profile, and if that context has no matching XML file,
> > nothing is loaded. At least so we assume - there's of course nothing to
> > stop the setuphandler from having side effects even if the XML file is
> > not found. We *do* see a problem with importVarious-type hacks, though.
> > Here, people resort to checking for a "flag" (normally an empty text
> > file) to determine if the setuphandler should be run.
> > 
> > I believe this is fundamentally Bad(tm) for three reasons:
> > 
> >  - People don't expect it to work that way.
> >  - Authors of setuphandlers have to be a lot more careful about having
> > side effects on entirely alien packages.
> >  - It's impossible to predict which steps actually get run for an
> > extension profile.
> > 
> > Say, for example, that I wrote extension profile Y and I wanted to use
> > an import handler used in extension profile X. If X had been run (or in
> > fact, looked at under the Import tab, the registry filling happens as
> > soon as you look at a profile there, even without running it) at least
> > once, then it would get attempted for Y as well. If the appropriate XML
> > or flag file was found it'd be run.
> > 
> > But there is no way for Y to know that X was run (or looked at). In
> > fact, it may be that users of Y do not want X to be loaded at all.
> > 
> > The only predictable way for Y's author to run said import step is to
> > explicitly list a setuphandler from X's package in Y's own
> > import_steps.xml.
> > 
> > I cannot see a good use case for the current behaviour, and it causes a
> > lot of confusion (either "why was this step run again?" or "why wasn't
> > this step run?"). Having to have flag files for pure-python
> > setuphandlers is also pretty hacky (even if such handlers themselves are
> > a bit hacky, but sometimes unavoidable).
> 
> One example where the current behavior makes sense is when you write an
> add-on product which wants to install itself into a standard Plone site
> and change the settings of the Archetypes tool. The import handler for
> the Archetypes tool is only specified in the extension profile for
> Archetypes and not in the Plone base profile. It is however always
> installed into a Plone site via an import various step.
> 
> I think this kind of decoupling the different profiles into the packages
> they came from is a sensible idea. In order for that to work reliable we
> need to have some profile dependency support, though.

There is another benefit to the current approach: it makes it possible
to export the whole site configuration for all known export steps. If we
'couple' the steps with the current context you would have to select all
extension profiles and run an export on them by hand, which is quite
painful.

Wichert.

-- 
Wichert Akkerman <wichert at wiggy.net>    It is simple to make things.
http://www.wiggy.net/                   It is hard to make things simple.


More information about the Zope-CMF mailing list