[ZPT] How to create page template with python script

David Chandek-Stark chand012@mc.duke.edu
Thu, 13 Mar 2003 17:29:08 -0500


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)
doc.manage_addProperty('completed_on', field_completed_on, 'string')
doc.manage_addProperty('contact', field_contact, 'string')
doc.manage_addProperty('project_team', field_project_team, 'lines')
doc.manage_addProperty('project_url', field_project_url, 'string')
doc.manage_addProperty('projected_completion', field_projected_completion,
'string')
doc.manage_addProperty('submitted_by', field_submitted_by, 'string')
doc.manage_addProperty('submitted_on', field_submitted_on, 'date')
doc.manage_addProperty('summary', field_summary, 'text')
###################################################

It looks like I have to import ZopePageTemplate in order to access the
method for creating the ZPT, but Zope won't allow it:

Error Type: Unauthorized
Error Value: You are not allowed to access ZopePageTemplate in this context

Can someone clue me on the combination of code and permissions to get this
done?

Thanks,
David