[Zope3-dev] [DRAFT] local portlets and perspectives

Tonico Strasser contact_tonico at yahoo.de
Tue Aug 30 06:22:54 EDT 2005


Hi!

Jean-Marc Orliaguet schrieb:
> Anyway, pagelets or portlets whatever they called and no matter what
> data they produce (structured data or raw HTML) must be "pipe-able"
> through the rendering engine, i.e. they must return some data, the more
> "ready HTML" the data is the less reusable it will be.

Pipe-able, hmm. I think, *if* we could do define-slot and fill-slot 
stuff in Python code that would be very nice. We would have a "page" 
object that can "pipe" page components together.

A simple example with boxes (sorry, Zope 2 script, don't kill me):

##
page = context.Page(template=container.ZPT_A)

# aggregate macro-defs from other page template
page.macros.update(container.ZPT_B.macros)

# create list of Box instances (not rendered HTML)
b1 = container.box_a('demo', 'Demo', condition=some_condition)
# box 2 takes b1 as input
b2 = container.box_b('foo', 'Foo', some_arg=b1)

left_boxes = [b1, b2]

# make boxes available in PTs as 'lboxes'
page.lboxes = left_boxes

# now we have aggregated all informations
# ready to render

# calls pt_render of ZPT_A with extra context
return page.render()

##

ZPT_A:

<page>
   <body metal:use-macro="macros/body"/>
</page>

ZPT_B:

<body metal:define-macro="body">
   <!-- render boxes here -->
   <box metal:use-macro="macros/box_repeat"/>
</body>

box_repeat macro:

<div class="box"
      metal:define-macro="box_repeat"
      tal:repeat="box lboxes"
      tal:attributes="id box/id">
   <h1 class="box-header"
       tal:content="box/title"/>
   <div class="box-body"
        metal:use-macro="box/macros/body|default"/>
</div>

Just for your inspiration.

Tonico



More information about the Zope3-dev mailing list