Tim Hicks wrote:
Hi (Martin),Is it possible to assign a selection of portlets to a specific interface, rather than a specific content type? That is, can I do something like the following, where INTERFACE_CATEGORY has been substituted in for CONTENT_TYPE_CATEGORY? from plone.portlets.constants import INTERFACE_CATEGORY left_column = getUtility(IPortletManager, name="plone.leftcolumn") left_category = left_column[INTERFACE_CATEGORY] left_portlets = left_category.get('Weblog', None) # It may be that it hasn't been created yet, so just to be safe: if left_portlets is None: left_category[my_interfaces_dotted_name] = PortletAssignmentMapping() left_portlets = left_category[my_interfaces_dotted_name] for name, assignment, kwargs in DEFAULT_LEFT_PORTLETS: if not left_portlets.has_key(name): left_portlets[name] = assignment(**kwargs)
An IPortletRetriever is used to pick the portlets to be returned. It asks an IPortletContext what the "current" cateogories and their values are - so, we may return a tuple like ((CONTENT_TYPE_CATEGORY, 'Document',), (GROUP_CATEGORY, 'MyGroup',), (GROUP_CATEGORY, 'MyOtherGroup')). It then uses the category + value (in the order given) to look up global portlet assignments in an IPortletManager.
So yes - you can define new categories, and you can use the dict-like semantics of an IPortletManager to store them. The README.txt in plone.portlets (not plone.app.portlets) will tell you more about how this works.
Another thing you may want to think about is to use a more global portlet assignment category, but to register different IPortletRenderer's for different context interfaces. That way, you can use the same assignment but vary the rendering by interface (including local markers, of course).
Martin -- Author of `Professional Plone Development`, a book for developers who want to work with Plone. See http://martinaspeli.net/plone-book _______________________________________________ Product-Developers mailing list [email protected] http://lists.plone.org/mailman/listinfo/product-developers
