[Grok-dev] Re: Paris sprint final report: Plone on grok!

Martin Aspeli optilude at gmx.net
Sun Apr 27 16:46:09 EDT 2008

Lennart Regebro wrote:
> On Sun, Apr 27, 2008 at 9:55 PM, Martin Aspeli <optilude at gmx.net>
> wrote:
>> I kind of regret the assignment-vs-data-provider distinction. The
>> IPortletAssignment interface has a "data" property which is
>> supposed to return the data provider to use for rendering. The idea
>> was to support the use case where you make one assignment type that
>> e.g. lets the user pick a content item, and then depending on the
>> type of content item that was selected, you'd get a different
>> renderer.
> Ah, *that* explains that weird "Assignment" thingy. I think we want, 
> for the grokky-thingy. to not have to create an assignment unless we 
> want this distinction. We just want a data provider, and we want to 
> call it "Portlet", imo. It may be ambigous, but it's what people 
> expect to do.

Please don't. :)

First of all, all portlets have an Assignment class. It's the "data 
provider" that's optional.

Secondly, if you call this a "Portlet" you are basically redefining the 
vocabulary of portlets. I think it *may* make sense to have the base 
class for the assignment be called Portlet *if* other things are being 
made optional/inferred from it.

For example, if we had:

class MyPortlet(foo.Portlet):

and had the renderer be picked up from a myportlet.pt page template and 
not much else, then it makes a bit more sense.

Please also see my comment on 

>> - One portlet render could indeed be registered for multiple data
>> provider types, since a renderer is really just a multi-adapter in
>> the same way a view or viewlet is. However, I've never seen anyone
>> actually do this, so I'd consider it an edge case.
> I agree.
>> - A portlet renderer is a multi-adapter on '(context, request,
>> view, portlet_manager, data_provider)'. You can have multiple
>> renderers that vary on any of these. For example, you could have a
>> portlet that has a different renderer in a particular view (that
>> is, the current view that's rendered the whole page), or for a
>> different portlet manager (the portlet looks different in the main
>> column and the dashboard) or for a different context (the portlet
>> looks different on a document than it does on other types).
>> So, I think the case of having one assignment type with multiple
>> renderers is more common than having multiple assignment types
>> using the same renderer.
> Ah, right. So they should probably be defined as you define views, 
> with the assignment being the context.

Mmmm... probably, yes. But note that they *do* get a 'context' argument 
which is the context content object; the context *assignment* (really, 
the data provider) is passed in as the last adapted thing and is 
conventionally called 'data'.

Thus, you'll see template do things like:


to access property 'foo' of the assignment.


Author of `Professional Plone Development`, a book for developers who
want to work with Plone. See http://martinaspeli.net/plone-book

More information about the Grok-dev mailing list