I am trying to add filtering on my own dexterity type's custom field on freshly installed Plone 5.1. My steps:
-
Installed collective.collectionfilter by adding it to buildout.cfg's eggs
-
Added my Dexterity content type through the web - entered several fields, one of them has short title type_of_dish (choice field, 2 possible options).
-
Created a collection named "Folder", added an instance of my content type under the folder
-
Navigated to ZMI -> portal_catalog -> Indexes, selected FieldIndex, entered Id - type_of_dish, Indexed attributes -> type_of_dish, clicked add and reindexed.
-
Created an add-on using mrbob from an addon template, created an adapter as per collective.collectionfilter's documentation. Contents of filter_test/adapters/filter_adapter.py:
from collective.collectionfilter.interfaces import IGroupByModifier, IGroupByCriteria from zope.component import adapter from zope.interface.declarations import implementer @implementer(IGroupByModifier) @adapter(IGroupByCriteria) def groupby_modifier(groupby): groupby._groupby["type_of_dish"] = { "index": "type_of_dish", "metadata": "type_of_dish", "display_modifier": lambda it: it }
Also added this line in configure.zcml configure tag:
<adapter factory=".adapters.filter_adapter.groupby_modifier" name="modifier_1" />
Added a portlet to my Folder, selected Current path as Folder, group-by - type_of_dish, which appeared after I installed my adapter. After saving the portlet shows an error, the (part of) traceback in console is
Traceback (innermost last):
Module plone.app.portlets.manager, line 54, in safe_render
Module Products.Five.browser.pagetemplatefile, line 125, in __call__
Module Products.Five.browser.pagetemplatefile, line 59, in __call__
Module zope.pagetemplate.pagetemplate, line 137, in pt_render
Module five.pt.engine, line 98, in __call__
Module z3c.pt.pagetemplate, line 163, in render
Module chameleon.zpt.template, line 261, in render
Module chameleon.template, line 191, in render
Module chameleon.template, line 171, in render
Module 6a36905592c24c23c99c377a9a5a2126.py, line 232, in render
Module five.pt.expressions, line 161, in __call__
Module collective.collectionfilter.baseviews, line 88, in results
Module plone.memoize.volatile, line 73, in replacement
Module collective.collectionfilter.filteritems, line 117, in get_filter_items
TypeError: ('Could not adapt', <Folder at /ezonus/aplankas>, <SchemaClass plone.app.contenttypes.behaviors.collection.ICollection>)
What am I missing? Am I doing it the right way?