September 17th, 2002, 06:32 AM
python functions in dtml
I am a severe rookie (newbie) in the Zope/python enviroment. I therefore need some help on calling python functions in dtml code. I typed the following in one of my pages but to no avail:
<input type="text" value="<dtml-call expr="pyFeedback.doTotal('text1','text2')">" name="total:int:ignore_empty"> </td>
The function as you can see is called doTotal and it basically is supposed to display the sum of 2 values in text boxes. Am I on the right track?
September 18th, 2002, 06:40 PM
If you want the result of a Python expression put in place of your dtml tag, you need to use dtml-var. dtml-call evaluates an expression, but does not put the result of that expression into the rendered page.
Ever consider using ZPT? Things are much easier to read/maintain in it.
<input type="text" value="<dtml-var expr="pyFeedback.doTotal('text1','text2')">" name="total:int:ignore_empty">
Here's the same thing in ZPT:
No "tags in attributes" that way!
<input type="text" tal:attributes="value python:here.pyFeedback.doTotal('text1','text2')" name="total:int:ignore_empty">
September 21st, 2002, 02:37 AM
Thanks! Now to email....
Thank you for your help Lucas. I was really stressed about that one.
Now I have another problem. I am trying to email the text on a web page. The email gets to its destination but the contents are just gibberish! Is there a way that it can be received in another format apart from .dat? How about .doc or just the page as it is (html)?
I'd really appreciate your help.
September 21st, 2002, 03:10 AM
oh no! more function trouble!
I spoke too soon!
I have just tried to call the corrected function but it still has a problem. Is there a simpler way to display the total of several textboxes(with integer values) on a form in one textbox on the same form?
Is it possible for the "total" textbox to have a default state where it "totals" & displays the totals as soon as the form is active?
September 25th, 2002, 05:35 PM