[Zope] How to stop html_quoting in a Zclass method

R. David Murray bitz@bitdance.com
Mon, 10 Apr 2000 14:05:26 -0400 (EDT)


On Mon, 10 Apr 2000, Denis [iso-8859-1] Frère wrote:
> It could be the beginning of an answer. But why Python would html_quote
> a string and dtml wouldn't ?
> 
> Is there a solution but playing with <dtml-with> ?

DTML does a call of the object (ie: it invokes the object's __call__
method).  The Python expression "folder.method" results (by python
rules) in a call to the object's __str__ method, which prints out,
by python convention, some printable "representation" of the object.
In the case of a DTML method, that would be the DTML source, and
I guess it's URL quoted becuase the author of the __str__ method
figured a web page was the most likely context in which the str
method would get called, and quoting it would mean the source would
get displayed as originally entered when viewed in a browser (but
I'm guessing here; there could be something I haven't learned about
this part of the machinery!)

You can achieve the same effect as the dtml-with inside the python
expression by explicitly calling the object ("folder.method()").
Some of the other magic that dtml does on a call, though, is to
pass the 'client' and 'namespace' in to the called object as the
first two arguments.  So to produce the same effect as the dtml-with,
you have to do:

<dtml-var "folder.method(_.None,_)">

_.None is passing a null client, and _ is the dtml name space stack.

This is neither intuitive nor particularly pretty.  DC folks have
explained that the initial design of Zope never forsaw the exposure
of the Python within the DTML, and thus things are not as clear and clean
as one would ideally like.  I believe there may be some discussion
in the interfaces wiki about how to improve this.

--RDM