[Zope] Re: Rendering DTML from string

Dieter Maurer dieter at handshake.de
Mon Apr 5 03:40:39 EDT 2004


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



More information about the Zope mailing list