Dave Peticolas writes:
Hello, I am a Zope beginner and have a hopefully simple question. I want to use a dtml method to format the content of a dtml document which is the client object when the dtml method is called.
For example, <http://dtml_doc/dtml_method> would, if I understand correctly, invoke dtml_method with dtml_doc as the client object.
Given my understanding, I would think a statement such as the following in dtml_method
... <dtml-var this> ...
would produce the rendered contents of dtml_doc appropriate for display, i.e., the contents you would get with <dtml-var dtml_doc>.
However, said statement results in the rendered contents of dtml_doc with the html special characters escaped to display literally rather than be intepreted by the browser. You can read in the Zope Book or in
<http://www.dieter.handshake.de/pyprojects/zope/book/chap3.html> how "<dtml-var var>" works. Essentially, it looks up "var" and calls it, if it is callable. The result is then converted into a string. In your case, "this" is a method returning the object. As a method, it is callable. "<dtml-var this>" does this. The result is your DTML Document instance. It is then converted into a string (by calling its "__str__" method) with the result you see. You need to render (call) the result of "this" a second time. There are at least the following ways: 1. <dtml-let client=this><dtml-var client></dtml-let> This first calls "this" (giving your DTML Document and binding it to client) and then calls "client" (giving you the rendered page). 2. <dtml-var expr="_.render(this())"> This renders "this()" the same way "<dtml-var var>" would do when "var" where bound to "this()". Dieter