Skip to main content

New Plone collections and it how it might affect you

June 19, 2012

Shiny new collections

The new collections provide a much nicer query UI with live results. Gier Baekholt has a short video online showing them off: http://blip.tv/eric-steele/geir-baekholt-plone-app-collection-3386446

Upgrading Plone

When upgrading your plone site, the old collections will still be available to you only they're be label "Collection (old-style)." Old collections will NOT be migrated to new-style collections.

Add-on product compatibility

Most add-ons right now that use collections for their functionality are not currently compatible.

Enabling old-style collections

If you're starting a new Plone site from scratch, the old collections will not be enabled by default and you may still want to use them on your site--especially if you're running add-ons that depend on the old-style collections yet.

To manual enable old-style collections, follow these steps:

  1. Visit the ZMI(or append /manage onto the url of your plone site)
  2. Click "portal_types"
  3. Click "Topic (Collection (old-style))"
  4. Check the "Implicitly addable?"
  5. Click the "Save" button

Developing for old and new collections

New style collections still implement the queryCatalog method which results the results from the catalog query so most likely the only thing you'll need to change is interface registrations and references to portal_type.

I have just updated collective.plonetruegallery for the new collections so I'll share some tips on integrating.

Conditional ZCML

In order to be backward compatible, you should use conditional zcml for any registrations or code that needs to be loaded. The collective docs has a good section on how to do this.

A simple example in practice is:

<browser:page
  zcml:condition="installed plone.app.collection"
  name="myview"
  for="plone.app.collection.interfaces.ICollection"
  class=".views.MyView"
  permission="zope2.View"/>

Registering an interface for new collection

<class class="plone.app.collection.collection.Collection"
zcml:condition="installed plone.app.collection">
<implements interface=".interfaces.IGallery" />
</class>

Retrieve the raw query

from plone.app.querystring import queryparser
query = queryparser.parseFormquery(collectionobj, collectionobj.getRawQuery())