[Zope] Add ZPT at initialization Zope product
Nico de Boer
nico@nfg.nl
30 May 2002 17:02:28 +0200
Hi all,
I am working on a News product. I have build it in python. It is a
folderish product and I want that at initialization of the product a
ZPT is added in the product.
I have tried this with DTML Method and it works fine:
self.manage_addDTMLMethod('index_html',title='',file='contents of file')
But it isn't working for ZPT. I'm looking for a way to do this, cause
I need to use the ZPT in my product.
I've tried this:
parent = getattr(self, 'aq_parent', None)
self._createZPT(parent, 'ZPTid', 'title', 'Template')
def _createZPT(self, parent, id, title, content):
"""Add a PageTemplate to the News product"""
parent._setObject(id, ZopePageTemplate.ZopePageTemplate(id, text=content))
getattr(parent, id).pt_setTitle(title)
But got the following error from Zope:
AttributeError: 'None' object has no attribute '_setObject'
The getattr method seems to return None, but the object really has a
parent.
Am I forgetting something?
Thanks,
Greetz Nico