Login | Register For Free | Help
Search for: (Advanced)

Mailing List Archive: Zope: Users

Executing a text file as a ZPT from a product

 

 

Zope users RSS feed   Index | Next | Previous | View Threaded


schou.temp.1 at gmail

May 3, 2009, 12:26 AM

Post #1 of 4 (1236 views)
Permalink
Executing a text file as a ZPT from a product

Im am writing a product and would like to include ZPT's as part of the
product. Is there a way that I can evaluate a piece of text (preferrably
stored as a text file in the product folder) as a ZPT?

Thanks,

Jakob Schou Jensen


lists at zopyx

May 3, 2009, 12:29 AM

Post #2 of 4 (1147 views)
Permalink
Re: Executing a text file as a ZPT from a product [In reply to]

On 03.05.09 09:26, Jakob Schou Jensen wrote:
> Im am writing a product and would like to include ZPT's as part of the
> product. Is there a way that I can evaluate a piece of text
> (preferrably stored as a text file in the product folder) as a ZPT?

"evaluate"?

In general: ZPT and PythonScripts are stricted and can not access the
filesystem - except
through unrestricted Python code ("trusted code") e.g. through a browser
view or
an external method or product code.

-aj
Attachments: lists.vcf (0.31 KB)


tseaver at palladion

May 3, 2009, 1:37 PM

Post #3 of 4 (1136 views)
Permalink
Re: Executing a text file as a ZPT from a product [In reply to]

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Jakob Schou Jensen wrote:
> Im am writing a product and would like to include ZPT's as part of the
> product. Is there a way that I can evaluate a piece of text (preferrably
> stored as a text file in the product folder) as a ZPT?

Something like:

from App.Common import package_home
from OFS.SimpleItem import SimpleItem
from Products.PageTemplates.PageTemplateFile import PageTemplateFile

class MyClass(SimpleItem):

some_name = PageTemplateFile('some_name.pt',
package_home(globals())


Tres.
- --
===================================================================
Tres Seaver +1 540-429-0999 tseaver [at] palladion
Palladion Software "Excellence by Design" http://palladion.com
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.6 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

iD8DBQFJ/gCE+gerLs4ltQ4RAjlXAKC02WUqOT0kiPOBTbjHKv9GFIRPIQCfTIw8
YrYRr+irI11VLP9h6iJ+ps0=
=mOID
-----END PGP SIGNATURE-----

_______________________________________________
Zope maillist - Zope [at] zope
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 )


zopelist at betabug

May 4, 2009, 12:38 AM

Post #4 of 4 (1132 views)
Permalink
Re: Executing a text file as a ZPT from a product [In reply to]

(Sun, May 03, 2009 at 09:26:57AM +0200) Jakob Schou Jensen wrote/schrieb/egrapse:
> Im am writing a product and would like to include ZPT's as part of the
> product. Is there a way that I can evaluate a piece of text (preferrably
> stored as a text file in the product folder) as a ZPT?

Yes of course you can - and about every guide on writing your own product
shows you how to do it.

For example just look at my BetaBoring sample product:
http://papakiteliatziar.gr/BetaBoring

What you do is use PageTemplateFile:
from Products.PageTemplates.PageTemplateFile import PageTemplateFile
...
_www= os.path.join(os.path.dirname(__file__), 'www')
...
index_zpt = PageTemplateFile(_www+'/index.zpt', globals())

Regards,

Sascha

_______________________________________________
Zope maillist - Zope [at] zope
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 users RSS feed   Index | Next | Previous | View Threaded
 
 


Interested in having your list archived? Contact Gossamer Threads
 
  Web Applications & Managed Hosting Powered by Gossamer Threads Inc.