Choose a profile when installing a quickinstaller product (Plone 4)
Question
I had performance problems when loading MathJax dynamically in my Plone 4 application. Thus, I found the Plone integration at https://github.com/collective/collective.mathjax and, as I noticed it does the same, forked it, which works well; I included a current MathJax 2.3 and changed the profile to use the "local" copy.
Now I wonder whether it is possible to choose between "online"/"remote" behaviour (load everything from rackcdn.com
) and the "default" behaviour (use the included copy) by choosing a profile when installing the product in the Plone QuickInstaller Tool.
I changed the configure.zcml
like this:
<configure
xmlns="http://namespaces.zope.org/zope"
xmlns:browser="http://namespaces.zope.org/browser"
xmlns:genericsetup="http://namespaces.zope.org/genericsetup"
i18n_domain="collective.mathjax">
<browser:resourceDirectory
name="mathjax"
directory="resources/MathJax" />
<genericsetup:registerProfile
name="default"
title="collective.mathjax: default"
directory="profiles/default"
description="collective.mathjax default profile: Includes MathJax 2.3."
provides="Products.GenericSetup.interfaces.EXTENSION" />
<genericsetup:registerProfile
name="online"
title="collective.mathjax: online"
directory="profiles/online"
description="collective.mathjax online profile: Load MathJax dynamically from rackcdn.com."
provides="Products.GenericSetup.interfaces.EXTENSION" />
</configure>
Unfortunately I can't see the "online" profile in the QuickInstaller, not even after deinstalling the product and changing the version number.
Update: In the console output, I found the following text:
INFO CMFQuickInstallerTool Multiple extension profiles found for product
collective.mathjax
. Used profile:collective.mathjax:default
Is there some fundamental misunderstanding, or what can I do to let people choose?
Solution 3
To make an answer from the helpful comments of Ida and Keul:
- There is (unfortunately) no such thing as a choice between alternative profiles (which makes the name "profiles" slightly misleading here, IMO).
- To switch between profiles, I ended in having distinct branches. The process goes like this:
- Go to the product directory and switch to the desired branch, e.g.
git checkout <branch name>
- Restart Plone (otherwise it wouldn't notice the change, unless there was a new version number meanwhile)
- re-install the product;
- when all is well, update the
buildout.cfg
to reflect the change.
- Go to the product directory and switch to the desired branch, e.g.
OTHER TIPS
Plone Quickinstaller (both ZMI and Plone UI) will only display one profile as "installation" profile. The chosen ones will be the first found (alphabetically speaking).
To manually run a profile, go to the portal_setup
tool in ZMI, then go the the "Import" tab and select your wanted profile (the provided order here is a mess... you will probably find a very long combo box). At the end of the page select "Import all steps"
It is actually possible to have multiple "alternative" profiles show up in Quickinstaller - you just need to 'trick' GenericSetup by registering each profile for its own (sub)package.
So the trick is to put the profile definitions inside different configure.zcml
files that reside in different packages (directories), and making sure to include the <five:registerPackage package="."/>
directive in each configure.zcml
file.
While it works, I am not sure how recommendable this trick is: I found it in the dexterity.membrane
package, used as an example here:
First, a 'default' profile is registered completely normally in the main configure.zcml
of the dexterity.membrane
package. Nothing special - but note that it includes the content
subpackage:
<configure
xmlns="http://namespaces.zope.org/zope"
xmlns:five="http://namespaces.zope.org/five"
xmlns:i18n="http://namespaces.zope.org/i18n"
xmlns:genericsetup="http://namespaces.zope.org/genericsetup"
i18n_domain="dexterity.membrane">
<!-- Include configuration for dependencies listed in setup.py -->
<includeDependencies package="." />
<!-- Grok the package to initialise schema interfaces and content classes -->
<i18n:registerTranslations directory="locales" />
<include package=".behavior" />
<include package=".content" />
<!-- Register an extension profile to make the product installable -->
<genericsetup:registerProfile
name="default"
title="dexterity.membrane: behaviors"
description="Configuration for the dexterity.membrane behaviors"
directory="profiles/default"
provides="Products.GenericSetup.interfaces.EXTENSION"
/>
<!-- Note that the example profile is registered in the content
directory. It is registered in such a way that both profiles
are visible and can be installed separately. Any upgrade steps
for that profile are also defined there. -->
<genericsetup:upgradeStep
title="Update profile"
description="Dummy step to fix profile registration after rename."
source="1000"
destination="1001"
handler="dexterity.membrane.migration.dummy_step"
profile="dexterity.membrane:default" />
<adapter name="Title" factory=".indexers.Title" />
<!-- -*- extra stuff goes here -*- -->
</configure>
Here's the configure.zcml
of the said content
subpackage: Nothing special either, except for the (second) registerPackage
directive, and the second profile:
<configure
xmlns="http://namespaces.zope.org/zope"
xmlns:five="http://namespaces.zope.org/five"
xmlns:genericsetup="http://namespaces.zope.org/genericsetup"
i18n_domain="dexterity.membrane">
<!-- make this show up in the quickinstaller separately -->
<five:registerPackage package="."/>
<genericsetup:registerProfile
name="example"
title="dexterity.membrane: content"
description="Configuration for the dexterity.membrane example content type"
directory="../profiles/example"
provides="Products.GenericSetup.interfaces.EXTENSION"
/>
</configure>