How to create a PageTemplate with the API?

Hello,
I want to load a file from the file system and create a PageTemplate object. What I have is:

zpt = PageTemplate()
zpt.id = fname
with open(fullpath, mode='r') as zptfile:
    zpt.write(zptfile.read())
folder._setObject(fname, zpt, set_owner=0)

However, that creates a broken object. And if I remove set_owner=0, I get

AttributeError: 'PageTemplate' object has no attribute 'manage_fixupOwnershipAfterAdd'

How can I create the ZPT object? (Zope 4)

Why do you need a template aa persistent object in the context of Plone. A template belongs into a custom Plone policy package registered as a browser view. Everything else is not recommended.

Hi ZTM,
Not fully sure if you try doing something advanced - or simple never before tried do custom development for plone.

You can take a look in existing plone products for browser folder and find configure.zcml file
There you will see reference to templates (pt files) and class files (py files)

This is example that maybe can give you inspiration (line 133):

"broken" in what way? If this is "broken" in the ZODB sense, then it would usually mean that the ZODB in unable to load it (usually, because some class is missing).

The easiest way for you is likely to create the the page template via the ZMI; maybe to change later its code in a script.

the object is shown with an icon labeled "broken". When trying to open it (in the ZMI) I get "Resource not found".

The ZMI is not an option, I'm adapting Products.FSDump to do its reverse.

I sent a couple of email replies which apparently were lost (or pending moderation?). Just wanted to say thank you for your replies. In the meanwhile I solved the problem. I was using PageTemplate, instead I should use ZopePageTemplate.