Personal tools
You are here: Home Documentation Tutorials Understanding and Using GenericSetup in Plone Applying Policies at Site Creation Time
Support

Get Help

Join our chat rooms or support forums if you have more specific questions.

Plone Training
Learn how to design, build, and deploy a website in Plone through one of the numerous Plone training sessions around the world.
Find Plone training…
 
Document Actions

Applying Policies at Site Creation Time

A description of how to register extension policies that can be applied at site creation time, wherein we learn how customization policies have gone the way of the dodo.

Rob Miller

A detailed look at GenericSetup, wherein we will learn what it is and how it can be used within Plone.
Page 7 of 10.

Those of you who have been doing Plone product development for a while are probably familiar with customization policies.  Customization policies are site configuration bundles, defined in the older python-based semantics, that can be applied to a Plone site.  One of the more handy features of customization policies is that they could be made to show up as an option when the Plone site was first created.  If you didn't select one, you would get a default Plone site, but if you did, your site would get a bunch of extra configuration applied.

Unfortunately, customization policies are currently not supported in Plone 2.5.  There has been some justified grumbling about this; they were not given a suitable deprecation period.  The good news is that GenericSetup provides the same ability, and that it is quite easy to convert existing customization policies to GenericSetup profiles (although these profiles will consist of just a single handler that calls all of the pre-existing customization policy code).

First let's look at how GenericSetup profiles are defined.  This is done using a profile_registry mechanism provided by GenericSetup, which can be imported into your product as so:

from Products.GenericSetup import profile_registry

Also defined are some constants for specifying the type of profile you are registering:

from Products.GenericSetup import BASE, EXTENSION

Once you have done these imports, a simple call to the profile_registry will register your profile.  (Duh.)  Here is what this call looks like for the membrane product:


    profile_registry.registerProfile('default',
                                     'membrane',
                                     'Extension profile for membrane',
                                     'profiles/default',
                                     'membrane',
                                     EXTENSION,
                                     for_=IPloneSiteRoot)

I'm not going to go into a detailed description of all of the arguments (you can see the IProfileRegistry interface for that), but I will draw your attention to the final "for_" argument.  This allows you to specify an interface that denotes the type of portal that the profile is meant to be used with.  If you use the IPloneSiteRoot interface, defined for this purpose, then when you add a new Plone site, your profile will automatically show up as available to be applied when the site is created.  Here is a screen shot of the Plone add form when a number of extension profiles have been registered:


In order to create an Extension Profile from a Customization Policy, then, you would perform the following steps:

  1. Register an extension profile with the GenericSetup profile registry (don't forget 'for_ = IPloneSiteRoot').
  2. Add a single import step in import_steps.xml, which calls a 'runPolicy' handler.
  3. Write the runPolicy function, which should accept a 'context' argument, but which simply calls the same code that the customization policy calls.
Et voila!  You should now have a working extension profile that is functionally equivalent to the customization policy.  There won't be any export support, however; in order to get that, you'll need to do considerably more work in translating your older customization policy into a true XML based configuration.
 
by Rob Miller last modified June 15, 2006 - 16:18 All content is copyright Plone Foundation and the individual contributors.

For any issues with the web site functionality, please file a ticket.

Please consult the policy on plone.org content if you want your content published on this site.

Servers and hosting by