On Wednesday 04 January 2006 07:55, Łukasz Łakomy wrote:
> Create content type 'Portlet' that could have TAL as its content and when
> watched in browser TAL should be redered. My code is below.

You really should not call this a portlet. A portlet is very well defined by 
JSR 168. Note that the Zope community -- specifically CMF and Plone -- have 
misused the term for a long time.

> class PortletView:
>     def renderText(self):
>         portlet = IPortlet(self.context)
>         format = portlet.format
>         if format in ('HTML', 'Plain'):
>             return portlet.getText()
>         elif format == 'Structured':
>             struct = structurize(portlet.getText())
>             doc = DocumentWithImages()(struct)
>             output = HTMLWithImages()(doc, level=1)
>             return output
>         elif format == 'Page Template':
>             page_template = PageTemplate()
>             page_template.write(portlet.getText())
>             output = page_template()
>             return output
> But there is a problem. When I define a variable in template and call it
> its ok. But I cannot call 'context' variable (for example <div
> tal:content="context/title"/>). This is my traceback.

Well, of course this does not work. The ``PageTemplate`` class does not know 
magically about a context. Have a look at 
zope.app.pagetemplate.viewpagetemplatefile.ViewPageTemplateFile to see what 
is involved in making variables available.

Stephan Richter
CBU Physics & Chemistry (B.S.) / Tufts Physics (Ph.D. student)
Web2k - Web Software Design, Development and Training
Zope3-users mailing list

Reply via email to