[Zope] Python seems to render html, can this be turned off or escaped?

Jonathan Hobbs toolkit at magma.ca
Thu Dec 16 12:34:20 EST 2004


From: "Guidry, Wayne" <wguidry at anteon.com>
> You are correct that I was using <dtml-var expr="<functionName>"> to
> obtain the value in DTML, however I changed that after I realized that
> could be a problem and went into my python script and decided to test it
> by clicking on the "Test" tab at the top of the python code and it still
> rendered (which made me to believe it is the python that is rendering
> it).
>
> Anyway, the code I am using looks like this:
> (in python):
>     #PROBLEM BEGINS ON LINE BELOW#
>     tmpStr = "<area shape = \"rect\" coords=\"" + str(xmin) +"," +
> str(newymax) + "," + str(xmax) + "," + str(newymin) + "\" href =
> \"<dtml-var BASE5>/selectWhereClause?currentid=<dtml-var
> currentid>&selected=COM\"/>"
>     returnList.append(tmpStr)
>     count=count+1
> return returnList
>
> Now in DTML, I was calling it like this:
>     <dtml-var "computeCoords()">
>
> Perhaps the "Test" tab is using DTML to render the python also?!
>
> If so, is there a way to force DTML not to render the text until I am
> ready for it to do so?

The problem is not with python, it is that when you click on the test tab at
the top of the python script editing page (within the ZMI) the data is being
displayed in your web browser - which interprets html commands.

If you want to see the html tags (for debugging purposes) when you click on
the 'test' tab try something like:

return '<textarea>'+mystring+'</textarea>

This will do two things:  (1) prove that it is your browser interpreting the
html tags in the string (because your browser will create a textarea field)
and (2) allow you to see the actual contents of 'mystring'

If you dont want to display the data when you get back to dtml, use the
dtml-call tag or the dtml-let tag to store the data in a local variable for
future use (instead of calling the python script with dtml-var).

HTH

Jonathan






More information about the Zope mailing list