[ZDP] BackTalk to Document The Zope Book (2.5 Edition)/Using Basic Zope Objects

nobody@nowhere.com nobody@nowhere.com
Fri, 20 Sep 2002 16:54:22 -0400


A comment to the paragraph below was recently added via http://www.zope.org/Documentation/Books/ZopeBook/current/BasicObject.stx#2-60

---------------

    This will return the balance or debt compounded over the course of
    "years".  Next, create a *interestRateDisplay* page template that
    calls *calculateCompoundingInterest* and returns the result::

      <html>
        <body>

        <p>Your total balance (or debt) including compounded interest over
        <span tal:content="years">2</span> years is:</p>
        <p><b>$<span tal:content="python: here.calculateCompoundingInterest(principal, 
                                                           interest_rate,
                                                           periods,
                                                           years)" >1.00</span></b></p>

        </body>
      </html>                                                           

      % Anonymous User - Apr. 6, 2002 10:39 am:
       Zope Error
       Zope has encountered an error while publishing this resource.

       Error Type: Undefined
       Error Value: years not found in 'years', at line 5, column 3
       ....
       ....

       # I got this error message, please help me to correct this error.

      % Anonymous User - Apr. 8, 2002 4:33 pm:
       i refer to the ch.9.
       and change the python expression to 
       python: here.calculateCompoundingInterest(request.form['principal'],... 
       that should be able to work.

       i'm a rookie.

      % Anonymous User - Apr. 11, 2002 9:53 am:
       You also need to change 
       tal:content="years" to
       tal:content="request/years"

       See ch.5

      % Anonymous User - Apr. 22, 2002 10:11 pm:
       create a interestRateDisplay page template that calls calculateCompoundingInterest and returns the result:
       <html>
         <body>

         <p>Your total balance (or debt) including compounded interest over
         <span tal:content="request/years">2</span> years is:</p>
         <p><b>$<span tal:content="python: here.calculateCompoundingInterest 
                                          (request.form['principal'],
                                           request.form['interest_rate'],
                                           request.form['periods'],
                                           request.form['years'])">1.00</span></b></p>

         </body>
       </html>
       #from Apr. 6, 2002 10:39 am:thank you! it works!

      % Anonymous User - June 5, 2002 5:19 am:
       My interestRateDisplay page template doesn't seem to be calling the Python Script.
       It just shows:

       Your total balance (or debt) including compounded interest over 2 years is:

       $1.00

       I must be missing something.

      % Anonymous User - June 5, 2002 5:43 pm:
       Ok, I realised that Zope Templates were not installed on my Zope. I had thot it was there by default. After
       proper installation, the scripts are now being called nicely. Thanks.

      % Anonymous User - June 13, 2002 9:05 pm:
       I suggest improving the information given in error output. I know this makes me sound dumb, but it took me 15
       minutes to realize that the problem I had was that I'd spelled calculate incorrectly in my script name. Why
       not have a message "error: script file calculteCompoundingInterest not found"

      % Anonymous User - June 24, 2002 10:51 am:
       I cannot understand the syntax for the interestRateDisplay template. What is the "..tal:content=..."
       attribute. Why do we have the number "2" between the openining and closing <span> tag and what is the "1.00"
       before the last closing </span> tag? Besides why do we need the "here" when we call the python python script?

      % Anonymous User - July 7, 2002 12:06 am:
       For properly namespaced XML, it would be appropriate to have an xmlns:tal attribute attached to the document
       root element. However, setting any value for xmlns:tal seems to disable the dynamic features on the server
       side.
       Is there an official namespace for the tal prefix?

      % Anonymous User - July 7, 2002 12:19 am:
       Disregard last comment:  found it in Appendix C.  

       xmlns:tal="http://xml.zope.org/namespaces/tal"

      % Anonymous User - July 11, 2002 11:34 am:
       I am getting the same problem as was posted by Anonymous User on the June 5th with my win98 installation. The
       python script returns with $1.00. I have tried to find more info on installing Zope Templates but have not
       succeeded. Please help!

      % Anonymous User - July 24, 2002 5:19 pm:
       My I humbly suggest eliminating the errors in this example as they appear so eary in this document, a user
       such as myself who has less than average familiarity with these technologies may waste an hour or so trying
       to figure out why they keep getting error messages when they cut and paste directly from the examples. It
       might lead a novice to postulate that they had installed Zope incorrectly, somehow.

      % Anonymous User - Aug. 3, 2002 1:54 pm:
       I'm thinking that a novice is more likely not to trust anything in this book, after this bad example. --RAW--

      % Anonymous User - Aug. 14, 2002 1:53 pm:
       THANK YOU whoever put in the full html a while back. It worked, and it only took me a few tries to check my
       own work against it

      % Anonymous User - Aug. 18, 2002 3:50 pm:
       I managed to get it running by pasting the "Anonymous User - Apr. 22, 2002 10:11 pm" comment's code. But it
       would be good for the book to take at least a sentence each to define:
       tal:
       request.
       request/
       <span>

       As far as I can tell, none of those are defined previously in the document, and they're not obvious.

      % Anonymous User - Sep. 9, 2002 11:46 am:
       Do not assume that your readers understand what happens at

       <span tal:content="python: ...

       I am a full-time webmaster, and this is Greek to me. I can guess what's happening, but I'd much rather have
       it explained to me.

      % Anonymous User - Sep. 10, 2002 11:21 am:
       I now find that the tal:content element is covered in Chapter 5 (under "How Page Templates Work"). Here, at
       the very least, a link to that explanation of tal syntax is necessary. You're really tripping up your readers
       by using it in example code, but not explaining it.

      % hansa - Sep. 20, 2002 4:54 pm:
       Well i know tal is pushed by zope folks, 
       but would a dtml-example not be more understandable?
       And maybe use local variables for request/years etc (in DTML: "let").
       To a newbie this all is still pure magic (and rookies dont know the spells).