RE: [Zope] Python seems to render html, can this be turned off or escaped?
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): oldList = context.imageCoordsFile.data newList = oldList.split("\n") count=0 lstCount = len(newList) returnList=[] tmpStr="" for j in newList: imgList = j.split(',') xx1=convertx(float(imgList[1])) yy1=converty(float(imgList[2])) cx1=convertx(float(imgList[3])) #distance (radius) from center of new x value cy1=converty(float(imgList[4])) #distance (radius) from center of new y value cx1 = cx1 *.5 #reduce the size of the coordinate radius by 50% (otherwise mapped images will overlap) cy1 = cy1 *.5 xmin=int(xx1-cx1) xmax=int(xx1+cx1) ymin=int(yy1-cy1) ymax=int(yy1+cy1) newymin=x2-ymax newymax=x2-ymin #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? Thanks again -----Original Message----- From: Jonathan Hobbs [mailto:toolkit@magma.ca] Sent: Thursday, December 16, 2004 10:19 AM To: Guidry, Wayne; zope@zope.org Subject: Re: [Zope] Python seems to render html,can this be turned off or escaped? From: "Guidry, Wayne" <wguidry@anteon.com>
I am trying to pass a string into a dtml document (from python) that contains html code, however I don't want python to render it, just pass it.
As an example...
mystring = "<html><body<h1> test1 </h1></body></html>" return mystring
'mystring' needs to be returned to my DTML document as a string, not as rendered html (which it seems to do automatically). Is this possible to do?
I don't think python is converting the string to html. What are you doing with the string once it is in the dtml method (ie. how did you invoke the python script?) Something like: <dtml-call "REQUEST.set('avar', myScript() )"> or <dtml-let avar="myScript()"> should put the data from 'mystring' as text into the dtml variable 'avar' if you do: <dtml-var myscript> then dtml will render the contents of mystring to html If you are still having problems, post another message with the dtml & python code. HTH Jonathan
From: "Guidry, Wayne" <wguidry@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
participants (2)
-
Guidry, Wayne -
Jonathan Hobbs