RE: [Zope] Re: Rendering DTML from string
That's exactly what I have, DTML code in a text file. It's been generated by python and contains "<dtml-XXX ???>" tags. I want read and execute the text file in Zope. The reason the above file resides on the local file system rather than within Zope is a design choice. I felt it would make life easier for us in certain respects. I may have been wrong. When I use - <dtml-let routine="_.getattr(LFSfiles, 'testfile.txt')"> <dtml-var "_[routine]"> </dtml-let> I get the following error - Exception Type TypeError Exception Value expected string or Unicode object, ImplicitAcquirerWrapper found Traceback (innermost last): * Module ZPublisher.Publish, line 100, in publish * Module ZPublisher.mapply, line 88, in mapply * Module ZPublisher.Publish, line 40, in call_object * Module OFS.DTMLMethod, line 130, in __call__ <DTMLMethod instance at 0230FE90> URL: http://localhost:8080/testing/basetest/manage_main Physical Path:/apacheVirtualHost/testing/basetest * Module DocumentTemplate.DT_String, line 474, in __call__ * Module DocumentTemplate.DT_Let, line 76, in render * Module DocumentTemplate.DT_Util, line 201, in eval __traceback_info__: _ * Module <string>, line 1, in <expression> * Module AccessControl.ZopeGuards, line 67, in guarded_getitem TypeError: expected string or Unicode object, ImplicitAcquirerWrapper found testfile.txt is - <p><strong>DTML code</strong></p> <p><dtml-var expr="1+2+3"></p> Thanks again. Samir. -----Original Message----- From: Small Business Services [mailto:toolkit@magma.ca] Sent: Saturday, April 03, 2004 18:22 To: zope@zope.org; DaMann Subject: Re: [Zope] Re: Rendering DTML from string From: "DaMann" <hammerhead@linuxmail.org>
Doesn't work <dtml-var "_[someDTMLstrObj]">. I get the raw dtml in page source. Which doesn't display in the browser because browser doesn't understand DTML tags.
I am not familiar with the object you have stored in local file storage, but if you have the name of a dtml method stored in a variable (ie. variable routine contains 'x', where 'x' is the name of a dtml method) then you can execute that method via: <dtml-var "_[routine]"> If you have a text file containg dtml code and you want to execute that code, the only thing i can think of is to place that code into a dtml method and then execute the method, as follows: <dtml-call "REQUEST.set('routine', 'tst')"> <dtml-call "REQUEST.set('dtmlcode', '<dtml-var standard_html_header><dtml-var REQUEST><dtml-var standard_html_footer>')"> <dtml-comment> create the new method </dtml-comment> <dtml-call "manage_addDTMLMethod(routine, 'atitle')"> <dtml-comment> now put some content into the new dtml method </dtml-comment> <dtml-call "_.getitem(routine).manage_edit(dtmlcode, 'anewtitle2')"> <dtml-comment> now execute the new method </dtml-comment> <dtml-var "_[routine]"> To make this work with a text file containing dtml code, just replace the REQUEST.set('dtmlcode'... with the code to read your text file and store the contents in 'dtmlcode'. HTH Jonathan _______________________________________________ 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 )
Samir Mishra wrote at 2004-4-4 08:38 +0400:
That's exactly what I have, DTML code in a text file. It's been generated by python and contains "<dtml-XXX ???>" tags. I want read and execute the text file in Zope. The reason the above file resides on the local file system rather than within Zope is a design choice. I felt it would make life easier for us in certain respects. I may have been wrong.
When I use - <dtml-var "_[routine]">
I get the following error -
Exception Type TypeError Exception Value expected string or Unicode object, ImplicitAcquirerWrapper found
Python/Zope error messages are not to bad. It is worth to read them carefully: The above tells you that at place where a string was expected an ImplicitAcquirerWrapper" was found. It is almost always safe to translate "ImplicitAcquirerWrapper" to "Zope Object". Looking at your code, only the "routine" variable can be responsible for this behaviour and indeed the argument of "_[...]" must be a string and is (apparently) an object (probably a file object). Now to your special problem: rendering DTML code from a text file. * Why do you put DTML code in a text file? You should use DTML objects to store DTML code and not text files * When you really need a text file, you must convert their content to a DTML object and then render that. -- Dieter
Samir Mishra wrote:
That's exactly what I have, DTML code in a text file. It's been generated by python and contains "<dtml-XXX ???>" tags. I want read and execute the text file in Zope. The reason the above file resides on the local file system rather than within Zope is a design choice. I felt it would make life easier for us in certain respects. I may have been wrong.
Look at Kapil's FileSystemSite product or maybe the LocalFS product. And please stop torturing yourself with DTML, life is so much more fun with ZPT :-) Chris -- Simplistix - Content Management, Zope & Python Consulting - http://www.simplistix.co.uk
participants (3)
-
Chris Withers -
Dieter Maurer -
Samir Mishra