#1
  1. No Profile Picture
    Junior Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    Sep 2002
    Location
    kenya
    Posts
    0
    Rep Power
    0

    Exclamation python functions in dtml


    Hi guys.

    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?

    Rookie pythoneer.
  2. #2
  3. Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jan 2001
    Location
    St. George, Utah
    Posts
    63
    Rep Power
    37
    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.


    Fixed code:

    Code:
    <input type="text" value="<dtml-var expr="pyFeedback.doTotal('text1','text2')">" name="total:int:ignore_empty">
    Ever consider using ZPT? Things are much easier to read/maintain in it.

    Here's the same thing in ZPT:
    Code:
    <input type="text" tal:attributes="value python:here.pyFeedback.doTotal('text1','text2')" name="total:int:ignore_empty">
    No "tags in attributes" that way!
    Lucas Marshall
  4. #3
  5. No Profile Picture
    Junior Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    Sep 2002
    Location
    kenya
    Posts
    0
    Rep Power
    0

    Thumbs up 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.


    Mutinda.
  6. #4
  7. No Profile Picture
    Junior Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    Sep 2002
    Location
    kenya
    Posts
    0
    Rep Power
    0

    Unhappy 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?

    Mutinda.
  8. #5
  9. Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jan 2001
    Location
    St. George, Utah
    Posts
    63
    Rep Power
    37
    So, you want to be able to enter a couple of numbers in a couple of text boxes and have the sum of the two display in another text box on the same form? If so, that's not a job for any server side language... it's a job for JavaScript.
    Lucas Marshall

IMN logo majestic logo threadwatch logo seochat tools logo