[Zope3-Users] Named layouts for z3c.pagelet

Ilshad astoon.net at gmail.com
Wed Oct 8 22:34:39 EDT 2008


Hello,

I need use several layout templates in same layer for z3c.pagelet-based
browser views.
For this, in current project I did follow:

renderer.py:

from zope.component import getMultiAdapter
from z3c.template.interfaces import ILayoutTemplate

def layoutRenderer(self):
        """Allow to use named layout templates."""
        try:
               name = self.layout_name
        except:
               name = u''

         self.update()
         if self.layout is None:
                layout = getMultiAdapter((self, self.request),
ILayoutTemplate, name)
                return layout(self)
         return self.layout()

So, a pagelet's code look like:

from .... renderer import layoutRenderer

class Pagelet(object):
    __call__ = layoutRenderer

    ....

and usual pass the name into zcml-directive:

<z3c:pagelet
    ...
    layout-name="narrow"
    />

And layout-directive from z3c.template allow define name.

Summary, it quite convenient. But my proposal - let's add this feature into
z3c.pagelet package.

-- 
Ilshad Habibullin
Gadoz, Inc (http://www.gadoz.com)
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mail.zope.org/pipermail/zope3-users/attachments/20081009/952fd95f/attachment.html 


More information about the Zope3-users mailing list