[Zope] How To Convert Files To Page Templates?

Nancy Donnelly nancydonnelly2006 at yahoo.com
Wed Nov 8 07:06:49 EST 2006


73----- Original Message ----
From: Maciej Wisniowski <maciej.wisniowski at coig.katowice.pl>

> I'm not sure whether it is what you're looking for but
> it may be one of simplest solutions that you may
> change if you need to. As Andreas said before,
> ask a specific question :)

> 1. Log into ZMI and create a folder called 'Myfiles'

> 2. upload your files via FTP or something into 'Myfiles' folder
> and as you said before they should appear as 'File' objects

> 3. Create a file 'files2zpt.py' in the 'Extensions/' folder of your Zope
> instance (filesystem, not ZMI) and fill it with this code:

> #----------------
> from Products.PageTemplates.ZopePageTemplate import ZopePageTemplate

> def files2zpt(self):
>     for fname, fobj in self.objectItems('File'):
>         self._setObject(fname+'_zpt', ZopePageTemplate(fname+'_zpt', 
> str(fobj.data)))
>     return 'ok'
> #-----------------

> 4. Go back to ZMI and to 'Myfiles/' folder and create
 'External method' 
> there
> by simply filling all fields in the add form as 'files2zpt'

> 5. Click on your new External method files2zpt in ZMI and 'Test' it :)

> Thats all

Thank you so much! Worked like a charm ;)
Nancy






-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mail.zope.org/pipermail/zope/attachments/20061108/10ee99ca/attachment.htm


More information about the Zope mailing list