[Zope3-dev] Portlets vs Pagelets

Garrett Smith garrett at mojave-corp.com
Mon Dec 6 17:55:28 EST 2004


Jean-Marc Orliaguet wrote:
> Jim Fulton wrote:
>> How do the current patterns deal with shared resources?
>> 
>> For example, if we have five widgets that all share the same
>> javascript code, we'll get 5 copies of that code.  It's
>> even worse for pagelets with needed visable resources like tool bars.
>> 
> Hi,
> 
> Indeed, how can a page template know how many widgets it contains for
> instance? especially if it define slots? Page templates are OK for web
> designers who read the code, but apart from that they have no
> knowledge about objects around them, neither "before" or "after"
> logically speaking. 
> 
> This shows the need to move away from page templates to handle the
> logic and treat this inside python classes using real zope objects,
> schemas, layouts, widgets, etc. In CPSPortlets the javascript code is
> only shown once per page even if several portlets use the same code,
> and not shown at all if no portlet uses javascript code, but the
> logic is done way before the page is displayed and it is done in
> python. 
> 
> The current pattern is: page template calls python. turn it around,
> i.e. python calls page templates.

I don't think there's one rule to follow here. In practice, Zope pages
are rendered using both approaches. There's even a third: Python
generates HTML algorithmically (e.g. widgets).

My take is that it depends on your application. If you're doing a
portal, it might make more sense to create an abstract layer along the
line of schema/widgets. In other cases, it's nice to just hard-code the
UI and fill in small pieces with Python generated content.

This is why I keep coming back to the goals underlying the 'portlet vs
pagelet' debate. So far I see two:

- Handle UI that uses JavaScript, CSS styles, or other resources that
should not be duplicated on a page

- Improve the control/felxbility over how UI is displayed on a page
(this control/flexiliby might be extended to an admin or end user role,
e.g. in the case of a portal)

 -- Garrett


More information about the Zope3-dev mailing list