[Zope3-dev] Portlets vs Pagelets

Phillip J. Eby pje at telecommunity.com
Mon Dec 6 18:29:15 EST 2004


At 04:55 PM 12/6/04 -0600, Garrett Smith wrote:
>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

For what it's worth, Ty Sarna and I implemented a pair of custom DTML tags 
for Zope 2 to handle this, called "Cut" and "Paste".

The basic idea is that you used something like:

     <dtml-cut js.foo_resource once="yes">'
     # JS code goes here
     </dtml-cut>

To define a resource, and:

     <dtml-paste js></dtml-paste>

To position it.  The basic idea is that there is a "hierarchical clipboard" 
of page content, that could be divided into e.g.  'head.*' and 'body.*', 
e.g. 'head.css' and 'head.scripts', etc.  Pasting a given piece of content 
outputs all text that is *hierarchically contained* in that section, so 
above pasting 'js' pastes all js.* content that has been written.

The 'once="yes"' part of the cut tag means to only insert the contained 
content into the "clipboard" if no text has previously been written to that 
address.  So, there can be only one 'js.foo', and if more than one DTML 
snippet requests the definition of that resource, the subsequent attempts 
will just skip the body of the dtml-cut tag.  (So, in effect, the body of a 
resource definition gets run only once.)

You can find the implementation at:

http://cvs.eby-sarna.com/ZProducts/CutAndPaste/

It's a good 4 years old, so the code would need some updating, even if you 
decided to use it as-is (which I doubt you will).

Anyway, the basic usage of this was that you'd define your page such that 
it "cut" its contents, and then at the end you'd invoke a template that 
would do all the pasting according to your page standards.  In a way, it 
was like a crude METAL macro, except that you filled the slots before 
invoking the macro, and you can call other templates that filled macro 
slots, and the slots are hierarchical, and you could choose not to add to a 
slot that already had content, or you could just add to a slot, 
and...  Hm.  I guess it's nothing at all like METAL.  ;)



More information about the Zope3-dev mailing list