Re: [Zope] How To Convert Files To Page Templates?
83----- Original Message ---- From: Chris Withers <chris@simplistix.co.uk> Nancy Donnelly wrote:
Hi;
I'm redoing a bunch of documents on a Zope site on my PC and I realized it >> would be easier to simply delete all the old ones and upload all the new ones. >> But if I do that, they'll load as "files", not "page templates".
How are you creating these new objects?
In a text editor.
I'd hazard a guess that you're looking to create a PUT_factory so that objects of the correct type are created when you upload things via FTP or WebDAV...
That helped a lot! I yahoo'd (can't google any more since they've sold out to the interests gathering our personal data for Homeland Security) "put_factory" and got this code snippet: if ext == 'dtml': from OFS.DTMLDocument import DTMLDocument return DTMLDocument( '', __name__=name ) So...how would I rewrite that to change it into a page template? And, more importantly, where is the documentation to do so? Yahooing didn't help on this. I went to my Zope installation to: {INSTALLATION}/lib/python/OFS to hunt around, but no script pointing to some "PTDocument" like there is with DTML. TIA, Nancy
On Tue, Nov 07, 2006 at 03:14:40AM -0800, Nancy Donnelly wrote:
That helped a lot! I yahoo'd (can't google any more since they've sold out to the interests gathering our personal data for Homeland Security) "put_factory" and got this code snippet:
if ext == 'dtml': from OFS.DTMLDocument import DTMLDocument
return DTMLDocument( '', __name__=name )
So...how would I rewrite that to change it into a page template? And, more importantly, where is the documentation to do so? Yahooing didn't help on this. I went to my Zope installation to: {INSTALLATION}/lib/python/OFS to hunt around, but no script pointing to some "PTDocument" like there is with DTML.
I think you want ZopePageTemplate from lib/python/Products/PageTemplates/ -- Paul Winkler http://www.slinkp.com
Nancy Donnelly wrote:
That helped a lot! I yahoo'd (can't google any more since they've sold out to the interests gathering our personal data for Homeland Security) "put_factory" and got this code snippet:
if ext == 'dtml': from OFS.DTMLDocument import DTMLDocument
return DTMLDocument( '', __name__=name )
So...how would I rewrite that to change it into a page template?
Here's a more complete PUT_factory that I use: from Products.PythonScripts.PythonScript import PythonScript from Products.PageTemplates.ZopePageTemplate import ZopePageTemplate from OFS.DTMLDocument import DTMLDocument from OFS.Image import Image from OFS.Image import File def PUT_factory( self, name, typ, body ): # Gimme a PageTemplate or a PythonScript, but never DTML! if typ=='text/x-python' or (body and body[0]=='#') or name.endswith('.py'): ob = PythonScript( name ) elif typ.startswith('text') or name.endswith('.pt'): ob = ZopePageTemplate(name, body, content_type='text/html') elif typ.startswith('image/'): ob = Image(name, '', body, content_type=typ) else: ob = File(name, '', body, content_type=typ) return ob hth, Chris -- Simplistix - Content Management, Zope & Python Consulting - http://www.simplistix.co.uk
participants (3)
-
Chris Withers -
Nancy Donnelly -
Paul Winkler