Newbie: creating objects programmatically
I am building a small application based on the "Build a simple ZClass (CatalogAware, non-default Catalog, Folderish)" how-to, but entirely using ZPT - I don't want to learn dtml! The objectManager constructor works fine with the lines as follows: instance = container.Directory.createInObjectManager(request['id'], request) instance.manage_addDTMLMethod('index_html','',instance.def_index) When I try to replace the dtml with: instance.manage_addProduct['ZopePageTemplate'].manage_addZopePageTemplate('memberIndex.pt') I get:Error Type: AttributeError Error Value: ZopePageTemplate when creating an instance of the ObjectManager ZClass. I have read many of the how-tos available, including the DTML to ZPT Conversions and hacked a lot but I can't find my error. Can someone help me please? Regards
Richard Jennings wrote:
When I try to replace the dtml with:
instance.manage_addProduct['ZopePageTemplate'].manage_addZopePageTemplate('memberIndex.pt')
Should be: instance.manage_addProduct['PageTemplates'].manage_addPageTemplate('memberIndex.pt') Cheers, Maik
When I try to replace the dtml with:
instance.manage_addProduct['ZopePageTemplate'].manage_addZopePageTemplat e('memberIndex.pt')
I get:Error Type: AttributeError Error Value: ZopePageTemplate
A couple of mistakes: 1) The name of page template product is 'PageTemplates', not 'ZopePageTemplate' 2) A name of ZPT constructor is 'manage_addPageTemplate' So it should be somthing like: container.manage_addProduct['PageTemplates'].manage_addPageTemplate ('memberIndex.pt') Note, that it will create a page template with default content. For other constructor parameters (title, text) peek into the file $ZOPE_ROOT/lib/python/Products/PageTemplates/ZopePageTemplate.py (IMHO, looking into the source code gives much more info than reading a bunch of manuals, at least if Zope is concerned :) Dmitry
participants (3)
-
Dmitry Dembinsky -
Maik Jablonski -
Richard Jennings