Re: [Zope] How To Convert Files To Page Templates?
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 ___ Zope maillist - Zope@zope.org http://mail.zope.org/mailman/listinfo/zope ** No cross posts or HTML encoding! ** (Related lists - http://mail.zope.org/mailman/listinfo/zope-announce http://mail.zope.org/mailman/listinfo/zope-dev )
Re: [Zope] How To Convert Files To Page Templates?
73- Original Message From: Maciej Wisniowski [EMAIL PROTECTED] 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 allThank you so much! Worked like a charm ;)Nancy___ Zope maillist - Zope@zope.org http://mail.zope.org/mailman/listinfo/zope ** No cross posts or HTML encoding! ** (Related lists - http://mail.zope.org/mailman/listinfo/zope-announce http://mail.zope.org/mailman/listinfo/zope-dev )
Re: [Zope] How To Convert Files To Page Templates?
72- Original Message From: Chris Withers [EMAIL PROTECTED]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:code follows...That's perfect! Thank you!Nancy___ Zope maillist - Zope@zope.org http://mail.zope.org/mailman/listinfo/zope ** No cross posts or HTML encoding! ** (Related lists - http://mail.zope.org/mailman/listinfo/zope-announce http://mail.zope.org/mailman/listinfo/zope-dev )
Re: [Zope] How To Convert Files To Page Templates?
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? 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... cheers, Chris -- Simplistix - Content Management, Zope Python Consulting - http://www.simplistix.co.uk ___ Zope maillist - Zope@zope.org http://mail.zope.org/mailman/listinfo/zope ** No cross posts or HTML encoding! ** (Related lists - http://mail.zope.org/mailman/listinfo/zope-announce http://mail.zope.org/mailman/listinfo/zope-dev )
Re: [Zope] How To Convert Files To Page Templates?
83- Original Message From: Chris Withers [EMAIL PROTECTED]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/OFSto hunt around, but no script pointing to some "PTDocument" like there is with DTML.TIA,Nancy___ Zope maillist - Zope@zope.org http://mail.zope.org/mailman/listinfo/zope ** No cross posts or HTML encoding! ** (Related lists - http://mail.zope.org/mailman/listinfo/zope-announce http://mail.zope.org/mailman/listinfo/zope-dev )
Re: [Zope] How To Convert Files To Page Templates?
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 ___ Zope maillist - Zope@zope.org http://mail.zope.org/mailman/listinfo/zope ** No cross posts or HTML encoding! ** (Related lists - http://mail.zope.org/mailman/listinfo/zope-announce http://mail.zope.org/mailman/listinfo/zope-dev )
Re: [Zope] How To Convert Files To Page Templates?
- Original Message From: Paul Winkler [EMAIL PROTECTED]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/Hmm. Looking in that I find these two files that *might* be appropriate:PageTemplates.pyZopePageTemplates.pyThe latter is a wrapper for the former. The former defines the following class:class PageTemplate(Base):If this is the class I want to use, why only one argument? My example above cites exactly two arguments. And it is not a "base" I need to pass, is it?The latter defines the following class:class ZopePageTemplate(Script, PageTemplate, Historical, Cacheable, Traversable, PropertyManager):Why so many arguments? It doesn't look like those are any of the arguments I need to pass. None of the other files in that folder appeared to make sense, either.I confess I'm still quite green at programming, so if I'm wrong, please don't be too harsh ;) Any direction would be appreciated.TIA,Nancy___ Zope maillist - Zope@zope.org http://mail.zope.org/mailman/listinfo/zope ** No cross posts or HTML encoding! ** (Related lists - http://mail.zope.org/mailman/listinfo/zope-announce http://mail.zope.org/mailman/listinfo/zope-dev )
Re: [Zope] How To Convert Files To Page Templates?
+---[ Nancy Donnelly ]-- | - Original Message | From: Paul Winkler [EMAIL PROTECTED] | | 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/ | | Hmm. Looking in that I find these two files that *might* be appropriate: | | PageTemplates.py | ZopePageTemplates.py | | The latter is a wrapper for the former. The former defines the following class: | | class PageTemplate(Base): | | If this is the class I want to use, why only one argument? My example above | cites exactly two arguments. And it is not a base I need to pass, is it? | | The latter defines the following class: | | class ZopePageTemplate(Script, PageTemplate, Historical, Cacheable, |Traversable, PropertyManager): | | Why so many arguments? It doesn't look like those are any of the arguments I | need to pass. None of the other files in that folder appeared to make sense, | either. These are not arguments, they are baseclasses. -- Andrew Milton [EMAIL PROTECTED] ___ Zope maillist - Zope@zope.org http://mail.zope.org/mailman/listinfo/zope ** No cross posts or HTML encoding! ** (Related lists - http://mail.zope.org/mailman/listinfo/zope-announce http://mail.zope.org/mailman/listinfo/zope-dev )
Re: [Zope] How To Convert Files To Page Templates?
I confess I'm still quite green at programming, so if I'm wrong, please don't be too harsh ;) Any direction would be appreciated. TIA, 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 HTH BTW. I tested this on Zope 2.8.8 -- Maciej Wisniowski ___ Zope maillist - Zope@zope.org http://mail.zope.org/mailman/listinfo/zope ** No cross posts or HTML encoding! ** (Related lists - http://mail.zope.org/mailman/listinfo/zope-announce http://mail.zope.org/mailman/listinfo/zope-dev )
[Zope] How To Convert Files To Page Templates?
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". I know there's a way to convert between the two, but I don't remember how. Can someone help?TIA,Nancy___ Zope maillist - Zope@zope.org http://mail.zope.org/mailman/listinfo/zope ** No cross posts or HTML encoding! ** (Related lists - http://mail.zope.org/mailman/listinfo/zope-announce http://mail.zope.org/mailman/listinfo/zope-dev )
Re: [Zope] How To Convert Files To Page Templates?
--On 6. November 2006 08:30:45 -0800 Nancy Donnelly [EMAIL PROTECTED] 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. I know there's a way to convert between the two, but I don't remember how. Can someone help? TIA, Nancy Martin Aspeli gave you already the correct answer on the plone-users list. Any more help needed? If yes, file and page templates have APIs to be used by programmers. Write a migration script that performs the necessary steps by reading your old data, creating new objects and by add the old content to the new instances as needed. If you need more help, ask something specfic. -aj pgpHFV2J2oxOk.pgp Description: PGP signature ___ Zope maillist - Zope@zope.org http://mail.zope.org/mailman/listinfo/zope ** No cross posts or HTML encoding! ** (Related lists - http://mail.zope.org/mailman/listinfo/zope-announce http://mail.zope.org/mailman/listinfo/zope-dev )