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
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
-----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@palladion.com 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-----
(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
participants (4)
-
Andreas Jung -
Jakob Schou Jensen -
Sascha Welter -
Tres Seaver