This does not work either. With this I get the following traceback: Traceback (innermost last): Module ZPublisher.Publish, line 100, in publish Module ZPublisher.mapply, line 88, in mapply Module ZPublisher.Publish, line 40, in call_object Module Products.MyContainer.MyContainer, line 17, in manage_addMyContainerForm Module Shared.DC.Scripts.Bindings, line 306, in __call__ Module Shared.DC.Scripts.Bindings, line 341, in _bindAndExec Module Shared.DC.Scripts.Bindings, line 1, in ? Module Shared.DC.Scripts.Bindings, line 286, in _getTraverseSubpath AttributeError: 'str' object has no attribute 'other' return pt works with incorrect results...displays <PageTemplateFile at containerError> return pt.document_src() works to the extent that it actually displays what's in the ZPT but does not render any of the TAL. return pt.pt_render() does not work causing the traceback from my original message. return pt() gives me the above traceback. Unfortunately I cannot find any good documentation on ZPT. I could give up and do my checking in the ZPT itself but this does not lead to reusability. BTW, using Zope 2.7. Anyone out there with an example of how they've used page templates in a product? Thanks, Wyatt -----Original Message----- From: Santi Camps [mailto:santi@zetadb.com] Sent: Thursday, April 15, 2004 4:26 AM To: Wyatt Anderson Cc: zope-dev@zope.org Subject: Re: [Zope-dev] ZPT in Zope Products Wyatt Anderson escribió:
Hello All,
I am trying to use ZPT within a Zope Product I am trying to build.
I want to test the container type I am addding to to determine what
action to take. The following though
from Products.PageTemplates.PageTemplateFile import PageTemplateFile
def manage_addMyContainerForm(self, REQUEST):
pt = None
if self.meta_type in [ContainerType1, ContainerType2]:
pt = PageTemplateFile(zpt/addMyContainerForm, globals())
else:
pt = PageTemplateFile(zpt/containerError, globals())
return pt.pt_render()
This produces the following traceback in Zope:
Traceback (innermost last):
Module ZPublisher.Publish, line 100, in publish
Module ZPublisher.mapply, line 88, in mapply
Module ZPublisher.Publish, line 40, in call_object
Module Products.MyContainer.MyContainer, line 17, in manage_addMyContainerForm
Module Products.PageTemplates.PageTemplate, line 90, in pt_render
- <PageTemplateFile at containerError>
Module Products.PageTemplates.PageTemplateFile, line 73, in pt_getContext
TypeError: 'str' object is not callable
Ive checked out the code in PageTemplate.py and PageTemplateFile.py and cant
figure out what is going on. The line in question is
root = self.getPhysicalRoot()
Is it possibly some security thing? My class is setDefaultAccess(allow) for now.
Ive also tried simply
return pt
with no traceback but without the desired results as the object is returned.
Thanks in advance,
Wyatt
Try return pt() Santi Camps