[ZPT] Default POST type

Sim Harbert sim.harbert@zapmedia.com
Wed, 18 Apr 2001 11:47:40 -0400


Yes, that helps.  I was incorrectly calling
'Products.PageTemplates.PageTemplate()' instead of
'Products.PageTemplates.ZopePageTemplate()'.

This should make it much easier to use from FTP or PUT.

-Sim

Martijn Pieters wrote:

> On Wed, Apr 18, 2001 at 11:03:50AM -0400, Sim Harbert wrote:
> > Sorry, but I guess I am not enough of a Zope/Python guru to figure this out
> > myself.  What exactly do I need in the 'PUT_factory' function to get it to
> > create a Page Template instead of a DTML object?  I may get this if I keep
> > plugging away, but it isn't obvious to me yet.
>
> You need to create an External Method that'll create a ZPageTemplate
> object to be used to create the new object.
>
> An example:
>
>   from Products.PageTemplates.ZopePageTemplate import ZopePageTemplate
>
>   def PUT_factory(self, name, typ, body):
>       if typ in ('text/html', 'text/xml'):
>            return ZPageTemplate(name, content_type=typ)
>       return None
>
> If you save that as an External Method, and add it to a Folder where you
> want to be able to create ZPT objects when you upload HTML pages.
>
> This example PUT_hook will create a ZPT for you when the content type is
> text/html or text/xml. You can alter the if clause to create it under
> different circumstances, of course. You could sniff out the uploaded body
> (the 'body' parameter), or the id of the object (the 'name' parameter).
>
> Hope this helps!
>
> --
> Martijn Pieters
> | Software Engineer  mailto:mj@digicool.com
> | Digital Creations  http://www.digicool.com/
> | Creators of Zope   http://www.zope.org/
> ---------------------------------------------