[Zope] Call PageTemplateFile class instances

Peter Bengtsson peter at fry-it.com
Thu Nov 13 12:25:15 EST 2008


2008/11/13 Andrew Milton <akm at theinternet.com.au>:
> +-------[ Peter Bengtsson ]----------------------
> | I've kind of work it out. The trick is to write some boiler plate in
> | the class definition like this::
> |
> | from zope import traversing, component, interface
> | from zope.interface import implements
> | from zope.traversing.interfaces import ITraversable
> |
> | from Products.PageTemplates.PageTemplateFile import PageTemplateFile
> | class MyProduct(Folder):
> |
> |    implements(ITraversable)
> |    component.provideAdapter(
> |                 traversing.adapters.DefaultTraversable,
> |                             (interface.Interface,),ITraversable)
> |
> |    meta_type = "bla"
> |    page = PageTemplateFile('zpt/foo.pt', globals())
> |
> |    def render_page(self):
> |         html = self.page(self.REQUEST) # ERROR!!
>
>
> why do you do this double shuffle anyway, when you can directly call
> "page" and protect it if necessary...
>
> I certainly don't have the issue you're describing and I don't need to
> do all that implements garbage either.
>
> Are you sure you don't have some Product installed that's messing with
> it?

No I'm not sure.
Truth is that my product is more complicated than that but so I took a
risk thinking it'll be the same as the pseudo product code I wrote.


>
> --
> Andrew Milton
> akm at theinternet.com.au
> _______________________________________________
> Zope maillist  -  Zope at zope.org
> http://mail.zope.org/mailman/listinfo/zope
> **   No cross posts or HTML encoding!  **
> (Related lists -
>  http://mail.zope.org/mailman/listinfo/zope-announce
>  http://mail.zope.org/mailman/listinfo/zope-dev )
>



-- 
Peter Bengtsson,
work www.fry-it.com
home www.peterbe.com
hobby www.issuetrackerproduct.com


More information about the Zope mailing list