[ZPT] Adding a ZPT programmaticly

Peter Bengtsson mail@peterbe.com
Thu, 21 Jun 2001 11:00:04 +0200


It took me some time to realize that you can't just use
manage_addPageTemplate with ZPT to do what
manage_addDTMLDocument('id','title',"""<dtml-var showpage>""") does.

Here's how we create ZPT objects (don't ask where the parameters come from,
cause even I don't have to know)

    from Products.PageTemplates import ZopePageTemplate

    def _createZPT(self, parent, id, title, content):
        parent._setObject(id, ZopePageTemplate.ZopePageTemplate(id,
text=content))
        getattr(parent, id).pt_setTitle(title)


Is there not an easier way?