Personal tools
You are here: Home Documentation Tutorials Benefit NOW from using GenericSetup and Zope 3 technologies Registering a setup profile
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

Registering a setup profile

In this part, you'll learn what GenericSetup profiles are for and how you can make use of them. Herein, we create our own content type and register our view as its default view.

Daniel Nouri

Impress your colleagues by using GenericSetup and Zope 3 views efficiently and with minimal effort! This tutorial shows you how to add a new view, how to use it, how to add a new content type and how to hook it all up.
Page 4 of 5.

Next, we're going to register our own content type that uses the view that we just made (my-view.html) as its default view. The type will otherwise behave just like a normal folder.

We'll do this by registering a GenericSetup profile, which is a bunch of configuration settings that you can install in your Plone site. In order to register the profile, we need to add this to our MYPRODUCT/configure.zcml:

<gs:registerProfile
name="default"
title="MYPRODUCT profile"
directory="profiles/default"
description=""
provides="Products.GenericSetup.interfaces.EXTENSION"
for="Products.CMFPlone.interfaces.IPloneSiteRoot"
/>

If you're familiar with XML, you may have noticed that we're using another XML namespace. We'll have to define the gs namespace in the root configure statement in the same file, so that it becomes:

<configure
xmlns="http://namespaces.zope.org/zope"
xmlns:browser="http://namespaces.zope.org/browser"
xmlns:gs="http://namespaces.zope.org/genericsetup">

Now that we registered the configuration, we can write the actual configuration, which goes into the MYPRODUCT/profiles/default folder. This is what we need to put into MYPRODUCT/profiles/default/types.xml to register our own type:

<?xml version="1.0"?>
<object name="portal_types" meta_type="Plone Types Tool">
<object name="My Folder"
meta_type="Factory-based Type Information with dynamic views"/>
</object>

Now copy Plone's CMFPlone/profiles/default/types/Folder.xml into the MYPRODUCT/profiles/default/types/ directory (which you create first) and rename the file to My_Folder.xml. This file corresponds to what you see in the portal_types tool in the ZMI when you go to .../portal/portal_types/Folder/manage_propertiesForm.

In your new My_Folder.xml, change this:

<property name="default_view">folder_listing</property>

into:

<property name="default_view">my-view.html</property>

and change this:

<object name="Folder"
meta_type="Factory-based Type Information with dynamic views"

into:

<object name="My Folder"
meta_type="Factory-based Type Information with dynamic views"

Also, add my-view.html to the list of selectable views in the view_methods property in the same XML file. And then you might want to change the title of the new type in the title property.

Done! Now you can visit the portal_setup tool in the ZMI and apply your MYPRODUCT profile to your site. But that user interface isn't really nice. So let's write a QuickInstaller method instead, so that your Product can be installed as usual through the Plone interface.

For your Product to be quick-installable, add a MYPRODUCT/Extensions/install.py and do:

from Products.CMFCore.utils import getToolByName

def install(portal):
setup_tool = getToolByName(portal, 'portal_setup')
old_context = setup_tool.getImportContextID()
setup_tool.setImportContext('profile-Products.MYPRODUCT:default')
setup_tool.runAllImportSteps()
setup_tool.setImportContext(old_context)
return "Ran all import steps."

Note that this step will not be necessary anymore in the future, because the portal_quickinstaller tool is going to be aware of GenericSetup profiles starting with Plone 3.0.

Of course all of these steps work also of you use sensible names instead of MYPRODUCT and my-view.html etc., but be sure you change those names throughout your whole Product!

 
by Daniel Nouri last modified February 23, 2007 - 18:55
Contributors: Wim Boucquaert
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