Tonico Strasser wrote:
> 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.
yes, this is what cpsskins does:
- the "define-slot" is just a "cpsskins:slot" with a name identifier
('left', 'right', 'main' ...) which means that can be used on several pages.
- the "fill-slot" part has been the subject of the discussion the past
week in the "perspective" thread.
Currently the plan is to support the "perspective" way of filling slots
(1 perspective = 1 set of portlets) and the "local folder" way of
filling a slot, i.e. traversing the site starting from the site root to
the current folder, gathering all the portlets stored in each folder on
the path and displaying them into the slot that they belong to.
here is how the renderer works:
starting from the top node in the theme tree:
A) is the node a leaf?
=> YES: then render the node according to B)
=> NO: get the list of child nodes in the correct order, for every
node go to A)
B) for every filter associated to the node:
- is the filter is the first in the chain?
=> YES: then get the data from the leaf (getDisplayData())
=> NO: use the output of the previous filter in the chain and feed
it into the current filter
- if the filter is the last in the filter chain for that node, feed
the filtered data into the next renderer.
In this way, believe it or not, you can by changing a few lines in a
zcml file render a "theme editor" with all the AJAX stuff
or an HTML page ready to be displayed on a web page:
90% of all the components are reused, simply they are wired 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
> # 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()
> <body metal:use-macro="macros/body"/>
> <body metal:define-macro="body">
> <!-- render boxes here -->
> <box metal:use-macro="macros/box_repeat"/>
> box_repeat macro:
> <div class="box"
> tal:repeat="box lboxes"
> tal:attributes="id box/id">
> <h1 class="box-header"
> <div class="box-body"
> Just for your inspiration.
yes, this is the ZPT way of doing it :-)
Zope3-dev mailing list