[Zope-CMF] Re: Abusing GenericSetup during traditional installs

yuppie y.2006_ at wcm-solutions.de
Fri Jul 28 06:34:40 EDT 2006


Hi Martin!


Martin Aspeli wrote:
> I realise this isn't entirely kosher (and that yuppie has much better
> long-term ideas), but I am wondering if it's possible to invoke some
> GenericSetup handler code during a more traditional Extensions/Install.py
> install.
> 
> This is purely for convenience - but if I need a more traditional product
> install (with a UI for uninstall and so on), I can use CMFQuickInstaller or
> external methods. However, doing things like FTIs and workflow definitions
> with GS XML syntax is way more convenient and maintainable.
> 
> Is there some way I could invoke a handler explicitly, e.g. say "run the
> workflow installation handler on this particular XML file from my product
> only"? Or do handlers have pre-requisites of context and/or side-effects
> that make them usable only within the context of a GS import run?

You might have noticed already that GS has two sub-frameworks, one for 
configuration handlers and one for content handlers. My answer just 
applies to configuration handlers:

The adapters are explicitly made for using them outside the GS tool. 
Body adapters are multi-adapters for ISetupEnviron and the interface of 
the object, e.g. IActionsTool for the Actions Tool.

ISetupEnviron is a small interface that provides a generic logger object 
and the mode in which XML files are applied. GS doesn't ship with a 
class that implements only this minimal interface.

So if you have the XML body in 'body', the tool in 'obj' and the 
SetupEnviron in 'environ', these two lines are all you need:

importer = queryMultiAdapter((obj, environ), IBody)
importer.body = body


There are other solutions if your XML is part of a registered profile.

HTH,

	Yuppie



More information about the Zope-CMF mailing list