[Zope] Re: Rendering DTML from string
Samir Mishra
SamirMishra at cbuae.gov.ae
Sat Apr 3 23:38:04 EST 2004
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 at magma.ca]
Sent: Saturday, April 03, 2004 18:22
To: zope at zope.org; DaMann
Subject: Re: [Zope] Re: Rendering DTML from string
From: "DaMann" <hammerhead at 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 at 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 )
More information about the Zope
mailing list