ZPT instead of DTML in products - how?
Aloha, I'm crawling up the zope/python products learning curve...if I want to use ZPT instead of DTML for web interfaces (like index_html, manage_addForm, etc.), how do I specify that? For DTML I find tutorials and howtos showing this sort of thing: from Globals import DTMLFile index_html = DTMLFile('www/index_html', globals()) manage_addForm = DTMLFile('manage_addForm', globals()) ..what is the equivalent of the above for ZPT files instead of DTML files? thanks, John S. __________________________________________________ Do You Yahoo!? Yahoo! - Official partner of 2002 FIFA World Cup http://fifaworldcup.yahoo.com
John Schinnerer wrote:
I'm crawling up the zope/python products learning curve...if I want to use ZPT instead of DTML for web interfaces (like index_html, manage_addForm, etc.), how do I specify that? For DTML I find tutorials and howtos showing this sort of thing:
from Globals import DTMLFile
index_html = DTMLFile('www/index_html', globals()) manage_addForm = DTMLFile('manage_addForm', globals())
..what is the equivalent of the above for ZPT files instead of DTML files?
from Products.PageTemplates.PageTemplateFile import PageTemplateFile index_html = PageTemplateFile('www/index_html', globals()) manage_addForm = PageTemplateFile('manage_addForm', globals()) Not so bad, eh? ;-) Some minor notes: If you omit the file's extension as above, the file must have extension '.zpt'. If the base name of the file is different than the method name, you should add the keyword argument '__name__', as in: manage_addForm = PageTemplateFile('addForm', globals(), __name__='manage_addForm') Also, unlike DTMLFiles, PageTemplateFiles operate within the same restrictions as through-the-web PageTemplates (such as no access to names starting with underscores). Cheers, Evan @ 4-am
participants (2)
-
Evan Simpson -
John Schinnerer