Migrate collections with custom criteria from plone 2.5 to plone 3.x
Migrate collections with custom criteria does not work
I wrote this How To to describe others how I solved this problem - may it help them :)
Prerequisities
An old database running with Plone 2.5, Zope 2.x, Python 2.x, Windows XP. A new database running with Plone 3.x, Zope 2.x, Python 2.x, Windows XP; an archetype with at least one indexed content field, a smartfolder with criteria regarding this field.
Step by step
1. Add in the archetypes python code the line index="FieldIndex:brains":
from Products.Archetypes.atapi import * from Products.Archetypes.public import * from Products.ATReferenceBrowserWidget.ATReferenceBrowserWidget import ReferenceBrowserWidget from Products.CMFCore import permissions from Products.ThisProduct.config import VOCAB1 from Products.ThisProduct.config import VOCAB2 schema = BaseSchema.copy() + Schema(( StringField('name', required = 1, widget = StringWidget(label = 'Name'), ), StringField('searchable_attribute1', index="FieldIndex:brains", vocabulary = VOCAB1, widget = SelectionWidget(label = 'Searchable_attribute1', format='radio'), required = 1 ), StringField('searchable_attribute2', index="FieldIndex:brains", vocabulary = VOCAB2, widget = SelectionWidget(label = 'Searchable_attribute2', format='radio'), required = 1 ), ....
2. Add inside the file catalog.xml the code
<index name = "Searchable_attribute1" meta_type="FieldIndex"> <indexed_attrvalue="Searchable_attribute1"/> </index> <index name = "Searchable_attribute2" meta_type="FieldIndex"> <indexed_attrvalue="Searchable_attribute2"/> </index> <column value="getSearchable_attribute1"/> <column value="getSearchable_attribute2"/>
3. Add inside the file portal_atct.xml the code
<index name=" getSearchable_attribute1" description="foo" enabled="True" friendlyName="foo" i18n:attributes="description; friendlyName"> <criteria>ATSimpleStringCriterion</criteria></index><index name=" getSearchable_attribute2" description="bar" enabled="True" friendlyName="bar" i18n:attributes="description; friendlyName"> <criteria>ATSimpleStringCriterion</criteria></index>
4. Login into zope and go to Plone Catalog Tool at /Plone/portal_catalog
Open the
tab “Indexes” and add a new field index. Name it "getSearchable_attribute1" and leave the
Indexed-Attributes-Field empty. Repeat for any other Attributes you might want
to add.
Now open
the tab “Metadata” and add as Metadata both "Searchable_attribute1" and "Searchable_attribute2".
5. Go to ~/Plone/portal_atct/atct_manageTopicMetadata
You won’t see the new indices – don’t panic! There is a small link at the right side of the page saying: "All fields".
Follow it, and watch the newly added indices and metadata appear in the list below. Now, check the box “enable” and you are done. - The attribute should be visible in the dropdown menu you need to edit when configuring a collections search criteria.
Further information
For further explanation and examples on parts of this procedure, see
http://plone.org/documentation/manual/upgrade-guide/version/2.5-3.0/products/indexes-declared-in-archetypes-schemata-need-to-be-moved-to-genericsetup
http://plone.org/documentation/manual/archgenxml2/basics/attributes-fields/?searchterm=catalog.xml
and on plone 2.5
http://plone.org/documentation/how-to/using-topics

Author: