[ZPT] How to create page template with python script

David Chandek-Stark chand012@mc.duke.edu
Fri, 14 Mar 2003 09:24:36 -0500


It works--thanks!

--David


                                                                                                                
                      Clemens                                                                                   
                      Robbenhaar               To:       "David Chandek-Stark" <chand012@mc.duke.edu>           
                      <robbenhaar@espre        cc:       zpt@zope.org                                           
                      sto.com>                 Subject:  [ZPT] How to create page template with python script   
                                                                                                                
                      03/13/2003 06:00                                                                          
                      PM                                                                                        
                      Please respond to                                                                         
                      zpt                                                                                       
                                                                                                                
                                                                                                                




David Chandek-Stark writes:
 > I am trying to write a script that creates a custom folder object and
then
 > creates a page template in that folder. I have the folder creation part
 > working (mostly):
 >
 > ###################################
 > """
 > Create project folder from form data
 > """
 >
 > # assign value to id
 > id=field_project_id
 >
 > # create the folder
 > context.manage_addProduct['OFSP'].manage_addFolder(id,
 > title=field_project_title)
 >
 > # add project properties
 > doc=getattr(context, id)

... and adding a page template works (nearly) the same:

 doc.manage_addProduct['PageTemplates'].manage_addPageTemplate(
            pt_id, text=text)
 pt=getattr(doc, pt_id)

where "pt_id" is the id of the page template and "text" is the
raw text of the page template.

The code is untested cut & paste from some other product.

Anyway I hope it helps (or even works ;-)
Clemens