[Zope] Creating Page Templates using XML-RPC

Dieter Maurer dieter@handshake.de
Wed, 1 Jan 2003 20:34:47 +0100


Gordon Lai wrote at 2002-12-30 14:36 -0800:
 > * In looking through our site using the Zope manage
 > interface, it seems as though every page is
 > represented by a Page Template. Is this true? Do I
 > need to create 3000 Page Templates?
You can use Page Templates to do this but you do not need to.

You may look at the CMF to see how to separate content (Document, File) from
presentation (Page Template).

 > * If the previous is true, how do I create Page
 > Templates programmatically?
You use its constructor. This usually takes the form of

    ObjectManager.manage_addProduct[ProductName].ObjectConstructor(Arguments)

"ObjectManager" is the destination container (usually a folder),
"ProductName" is the product that defines the object class
("PageTemplates", in your case),
"ObjectConstructor" is the method constructing the instance
("manage_addPageTemplate", in your case),
"Arguments" are the arguments the constructor needs
("id,title,text", in your case, with "title" and "text" optional).

 > It seems XML-RPC can work
It is probably easier to use a wrapper.

But you can use XML-RPC directly. You would use the URL:

    URL_to_ObjectManager/manage_addProduct/ProductName

and call "ObjectConstructor" with the necessary arguments.
You will probably get a 302 response (this is a redirect response)
because Zope will make a redirect to the management page.
XML-RPC might convert this into an exception.

That's one reason why a wrapper is better.

 > for me, but I can't find an API to create Templates.
 > Does one exist, or should I be using a different
 > method?
The most elegant way would be to go for CMF (but, you would
need some time to get acquainted with CMF), because of the
clear separation of content and presentation.

An alternative to CMF/PageTemplates retaining the separation
of content/presentation would be to use "File" objects either

  *  presented via a PageTemplate (e.g. "File/view")

  *  or with an overridden "index_html".

An alternative to XML-RPC would be to use FTP/WebDAV together with
a so called "PUT_factory" (HowTo in zope.org).



Dieter