Friday, January 22, 2010

using a policy product to install (not just get) add-ons

We all know how you can use a policy product to automatically get add-on
products and do basic site configuration. If you don't look here: weblion.psu.edu/trac/weblion/wiki/CreateYourOwnProduct and vilmos.somogyi.name/plone-tutorial-new-policy-product-with-paster

But how to actually install these products and configure them when the policy
product is installed?

Use case: I'd like to create a policy egg that will not only download but also
install a custom theme, Products.LinguaPlone and Products.Collage. (Afterwards i want to set up LinguaPlone's available languages, and perhaps I'd also like to create translations for content that was added in the policy product's 'profiles/default/structure', but that's a different story.)

Solution:
In your profiles/default/metadata, add dependencies:
<dependencies>
<dependency>profile-Products.LinguaPlone:LinguaPlone</dependency>
</dependencies>

Note that the name of the GS profile is defined in the product, so it could be anything. Look for the genericsetup:registerProfile's name attribute.

Alternatively, you could call the quickinstaller's installProducts method from setuphandlers.py
    quickinstaller = portal.portal_quickinstaller
installable_products = [
'Products.Collage',
'Products.LinguaPlone',
]
for product_name in installable_products:
quickinstaller.installProduct(product_name)

, but that will also make products show up twice in Plone's add-on products panel. For mere products installation i would recommend the above method.

1 comment:

Ida Ebkes said...

I's a while ago now, but I wanted to let you know, that your post has been very helpful and is super clearly written, thanks! Regards, Ida