Automatically installing a GS profile from another product/library
Maurits van Rees
m.van.rees at zestsoftware.nl
Sun Sep 2 19:23:43 UTC 2007
Hello Tim,
Tim Hicks, on 2007-09-02:
> I have a product ('Products.Quills') that has a GenericSetup profile. I
> also have a library ('quills.app') that has a GS profile. When
> Products.Quills is installed by the QI tool (in plone3), its profile
> gets applied automatically. I want the quills.app profile to be applied
> automatically as well.
>
> To this end, I added an explicit call to:
>
> setup_tool.runAllImportStepsFromProfile('profile-quills.app:default')
>
> in my importVarious setup handler. However, when I do this, I seem to
> enter an infinite recursion. From what I can tell, when portal_setup
> tries to apply the 'quills.app:default' profile, it ends up running
> Products.Quills's importVarious again, which obviously leads to the
> runAllImportStepsFromProfile call again...
The thing to realize here is that *all* steps that have been
registered with GenericSetup are run. Somewhere there is a method
that is responsible for loading the info from the skins.xml file in
your profile. This method is run even when you do not have such a
file. The method checks if that file is there. If it is found, the
method does its thing. If the file is not found, the method returns
immediately.
> What's the right way of doing this?
You need to tell both setuphandlers to *only* run when their own
profile is being applied. For quills.app (if that has an
import_steps.xml) you would do that by adding an empty file (or with
just some plain text to clarify) named e.g. quills_app_various.txt in
your profile directory. Then in your setup handler check that this
file exists in the current import context and bail out if it is
missing:
def importVarious(context):
# Only run step if a flag file is present
if context.readDataFile('quills_app_various.txt') is None:
return
# Do your stuff here.
Same for Products.Quills, but choose a different file name there.
Read about it here:
http://maurits.vanrees.org/weblog/archive/2007/06/discovering-genericsetup
For examples, look at the eXtremeManagement code or look at
CMFPlone/profiles/default/plone_various.txt and grep in the CMFPlone
code for the 'plone_various.txt' string.
--
Maurits van Rees | http://maurits.vanrees.org/ [NL]
Work | http://zestsoftware.nl/
"Do not worry about your difficulties in computers,
I can assure you mine are still greater."
More information about the Product-Developers
mailing list