[Zope] Re: Rendering DTML from string

Samir Mishra SamirMishra at cbuae.gov.ae
Tue Apr 6 05:59:04 EDT 2004


Thanks Dieter, that was helpful. 

I'm using Python code outside Zope to generate templates containing DTML
tags. The tags are generated from (meta)data contained in a DB. The same
modules are also generating a number of other related documents. As I said,
it was a design choice, and, in hindsight, may be not the best one.

Would you recommend 
1. I move my Python modules generating the DTML code to External methods in
Zope?
2. Create DTML methods stored within Zope from the DTML-tagged files (using
manage_addxxx)?
3. Keep the external files and render the DTML in Zope?

I'm working on trying to figure out which functions/classes within
OFS.DTMLDocument and FileSystemSite.FSDTMLMethod I need for the rendering,
if you have any advice, it will be appreciated.

Thanks again,
Samir.


-----Original Message-----
From: Dieter Maurer [mailto:dieter at handshake.de]
Sent: Monday, April 05, 2004 11:41
To: Samir Mishra
Cc: 'Small Business Services'; 'zope at zope.org'
Subject: RE: [Zope] Re: Rendering DTML from string


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