[Zope3-dev] Portlets vs Pagelets

Jean-Marc Orliaguet jmo at ita.chalmers.se
Tue Dec 7 03:57:58 EST 2004


Garrett Smith wrote:

>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).
>
>  
>
Hi

Python can also call dtml code, the important aspect is that control 
over the application logic is given to Python and not to HTML or 
javascript or css, or you will end up doing hacks trying to tie together 
individual pieces of code.

>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
>  
>

The problems raised in these goals are easily solved if the logic is 
moved to python and why would you want to hard-code a UI? I am more 
inclined to a Visual (C++, Basic) approach with UI widgets assembled 
together than using some hardcoded template no matter if it is a webpage 
that is being designed or a portal. I am sure that some users need to 
update the webpage without having to learn page templates, don't they?

regards /JM



More information about the Zope3-dev mailing list