In this blog post, I describe to how to use collective.jsonify for exporting a
Writing Plone portlets is still pretty hard. Even as an experienced Plone programmer I usually have to check Martin Aspeli's book or check older code in order to remember how the implementation must look like. My general impression about the Plone portlets implementation: too complex, over-designed and unfriendly to average developers. So this blog entry tells you about some rough ideas about how portlet writing in Plone should look like from the prospective of a developer.
What are portlets?
Portlets are conceptually just a component providing a piece of HTML content that is rendered by some manager within some context. The concept of a (browser) view is basically pretty similar to the functionality of a portlet.
A simple portlet implemented with a template
In Plone 2 portlets were just simple page templates providing a dedicated macro "portlet". So portlet were very easy to write and configure (beside Plone 2 had no notion of portlet assigment). Within Plone I want to be able to write a small piece of template implementing the functionality and I want to be able to register it using ZCML with:
<plone:portlet for="my.package.interfaces.ISomething" title="My cool portlet" template="something_portlet.pt" />
No Python code involved - just a template and an easy snippet of ZCML registration
A simple portlet with some Python code
A portlet implementation might need some additional logic (because we don't want complex logic within our templates. So our implementation may look like a brower view:
class SomethingPortlet(SomeMagicPortletBase): template = ViewPageTemplateFile('something_portlet.pt') def helperMethod1(self): ..... def helperMethod2(self): ...
And the registration with Plone will look similar to a browser view:
<plone:portlet for="my.package.interfaces.ISomething" title="My cool portlet" class="something.SomethingPortlet" />
A portlet with configuration parameters
Complex portlet may need persistent parameters like #items to be displayed with the portlet. This is expressed through a schema (also similar with browser views):