GenericSetup and profiles

GenericSetup is an XML-based way to import and export Plone site configurations.

It is mainly used for prepare Plone site database for add-on product

  • Register CSS files
  • Registering Javascript files
  • Setting various properties
  • Registering portlets
  • Registering portal_catalog search query indexes
  • ...and so on...

GenericSetup is mostly used to apply add-on specific changes to the site configuration and enabled add-on specific behavior when the add-on installer is run.

GenericSetup XML files are usually under profiles/default folder inside the add-on product.

All run-time configurable items, like viewlets order through /@@manage-viewlets page, are made repeatable using GenericSetup profile files.

You do not need to hand-edit GenericSetup profile files. You can always change the configuration options through Plone or Zope Management Interface. Then you can produce the profile XML file using Export tab in portal_setup ZMI tool.

Directly editing XML profile files do not change anything on the site, even after Zope restart. This is because run-time configurable items are stored in the database. If you edit profile files, you need reimport edited files using portal_setup tool or rerun the add-on product installer in Plone control panel. This import will read XML files and change Plone database accordingly.

Note

Difference between ZCML and GenericSetup

ZCML changes affect loaded Python code in all sites inside Zope whereas GenericSetup XML files affect ony one Plone site and its database. GenericSetup XML files are always database changes.

Relationship between ZCML and site-specific behavior is usually done using layers. ZCML directives, like viewlets and views, are registered to be active on a certain layer only using layer attribute. When GenericSetup XML is imported through portal_setup, or the product add-on installer is run for a Plone site, the layer is activated for the particular site only, enabling all views registered for this layer.

Creating a profile

You use <genericsetup> directive in your add-on product’s configure.zcml. The name for the default profile executed by Plone add-on installer is “default”. If you need different profiles for e.g. unit testing you can declare them here.

Profile XML files go to profiles/default folder inside your add-on product.

<configure
    xmlns="http://namespaces.zope.org/zope"
    xmlns:genericsetup="http://namespaces.zope.org/genericsetup"
    i18n_domain="gomobile.mobile">

    <genericsetup:registerProfile
      name="default"
      title="Plone Go Mobile"
      directory="profiles/default"
      description='Mobile CMS add-on'
      provides="Products.GenericSetup.interfaces.EXTENSION"
      />

</configure>

Add-on specific issues

Add-on product may contain

  • Default GenericSetup XML profile which is automatically run when the product is quick installer. The profile name is “default”.
  • Other profiles which the user may install through portal_setup Import or which can be manually enabled for unit tests
  • “Import various” step which runs Python code every time GenericSetup XML profile is installed

More information about custom import steps

Listing available profiles

Example:

# Run the default quick installer profile
setup_tool = self.portal.portal_setup

profiles = setup_tool.listProfileInfo()
for profile in profiles:
    print  str(profile)

Results:

{'product': 'PluggableAuthService', 'description': 'Content for an empty PAS (plugins registry only).', 'for': <InterfaceClass Products.PluggableAuthService.interfaces.authservice.IPluggableAuthService>, 'title': 'Empty PAS Content Profile', 'version': 'PluggableAuthService-1.5.3', 'path': 'profiles/empty', 'type': 1, 'id': 'PluggableAuthService:empty'}
{'product': 'Products.CMFDefault', 'description': u'Profile for a default CMFSite.', 'for': <InterfaceClass Products.CMFCore.interfaces._content.ISiteRoot>, 'title': u'CMFDefault Site', 'version': 'CMF-2.1.1', 'path': u'profiles/default', 'type': 1, 'id': u'Products.CMFDefault:default'}
{'product': 'Products.CMFPlone', 'description': u'Profile for a default Plone.', 'for': <InterfaceClass Products.CMFPlone.interfaces.siteroot.IPloneSiteRoot>, 'title': u'Plone Site', 'version': u'3.1.7', 'path': u'/home/moo/sits/parts/plone/CMFPlone/profiles/default', 'type': 1, 'id': u'Products.CMFPlone:plone'}
{'product': 'Products.Archetypes', 'description': u'Extension profile for default Archetypes setup.', 'for': None, 'title': u'Archetypes', 'version': u'1.5.7', 'path': u'/home/moo/sits/parts/plone/Archetypes/profiles/default', 'type': 2, 'id': u'Products.Archetypes:Archetypes'}
...

Installing a profile

This is usually unit test specific question how to enable certain add-ons for unit testing.

PloneTestCase.setupPloneSite

See Running add-on installers and extensions profiles for unit tests.

Manually

You might want to install profiles manually if they need to be enabled only for certain tests.

Profile name is in format profile-${product name}:${profile id}

Unit testing example:

# Run the extended profile which will create email_catalog
setup_tool.runAllImportStepsFromProfile('profile-betahaus.emaillogin:exdended')

Dependencies

GenericSetup profile can contain dependencies to other product profiles (and installers).