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)
_______________________________________________
Zope3-users mailing list
Zope3-users@zope.org
http://mail.zope.org/mailman/listinfo/zope3-users

Reply via email to