[Zope] How to use ZPT with ad-hoc context?

Daniel Dekany ddekany at freemail.hu
Mon May 4 05:41:21 EDT 2009

How to create a template context ("here" inside ZPT) that is not an
object from the ZODB, just a temporary object? This is what I tried:

class AdhocContext(Implicit):
    pt = PageTemplateFile("whatever/path",  globals())


  def whatever(self):
        ctx = AdhocContext().__of__(self)
        return ctx.pt()

The problem I have with this is that I can't access anything in
AdhocContext from the ZPT because the security manager blocks it (I
didn't forget to security.declarePublic + document what I wanted to
access). Is there a simple trick to solve this? (BTW, I will need to
invoke some Plone macros from that ZPT too... I hope that will just
work if this security matter is solved.)

Best regards,
 Daniel Dekany

More information about the Zope mailing list