[Grok-dev] "Apply" a pagetemplate to an object and get html back

Lennart Regebro regebro at gmail.com
Sat Jul 19 12:03:31 EDT 2008

On Sat, Jul 19, 2008 at 17:26, Achim Domma <domma at procoders.net> wrote:
> My problem is the convert_event_to_html method, if I want to use a page
> template to layout the events. Hope this makes my problem more clear?!

Yup. As you said, you make a view for the event, and then you find
that view and call it.

I'm guessing the problem is how to find the view? I'm not sure what
the easiet way in Grok is.

from zope.traversing.api import traverse
view = traverse(event, '@@theviewname')

or you can look it up via a multiadapter call, but that seem more
complicated (but is faster and probably the "correct" way of doing

Of course, if you used a ZPT template instead of generating teh HTML
in Python, it would be trivial.

Lennart Regebro: Zope and Plone consulting.
+33 661 58 14 64

More information about the Grok-dev mailing list