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

webmaster@zope.org webmaster@zope.org
Tue, 03 Dec 2002 15:04:23 -0500

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


    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::


        <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, 
                                                           years)" >1.00</span></b></p>


      % 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

       See ch.5

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

         <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 

       #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:


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


      % 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:

       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).

      % Anonymous User - Oct. 9, 2002 8:00 am:
       I think it should be emphasized here that a PAGE TEMPLATE must be used for the interestRateDisplay form. Prior
       to this topic, there was a discussion about DTML document. So all along I thought that the
       interestRateDisplay form is a DTML document. The PAGE TEMPLATE is still new to me at this point.
       If you use a DTML document, even with the suggested code for interestRateDisplay , the outcome will be wrong.
       It will always spill out 1.00 as the result.

      % Anonymous User - Nov. 13, 2002 4:35 pm:
       I'll try the code suggested above (April 2002) tonight. I too typed the example in as specified and triple
       checked everything for 30 minutes before giving up. For a "book" that is in revision 2.5, there is certainly
       no excuse for an example that doesn't work, especially considering the error has been identified quite a long
       time ago and I downloaded the most recent e-version of the book.
       This reeks of the "gotta feel the pain" mentality, someone rationalizing that this is not a big deal and if
       you're "truly committed" you'll get over it and learn how to use it. Yes I can overcome it and learn this
       tool and framework, but when the Zope World wants to know why there's only x number of programmers instead of
       x+1,000, one has to look no further than this example.

      % Andrew82 - Nov. 21, 2002 1:15 pm:
       The solution to the problem is to remove the spaces and quotes surrounding the expression, as follows:

       <dtml-var standard_html_header>

       <p>Your total balance (or debt) including compounded interest over <dtml-var years> years is:</p>
       <p><b><dtml-var expr=calculateCompoundingInterest(principal,interest_rate,periods,years)></b></p>

       <dtml-var standard_html_footer>

      % shunting - Dec. 3, 2002 3:04 pm:
       MANY THANKS to Anonymous User - Apr. 22, 2002 -- this worked for me (though I am using version 2.3.3 of Zope
       to stick with Python 1.5.2, so YMMMV).

       "yrs"->"years" not needed, probably a typo got fixed in the course of this change.

       The book says "calculateCompoundingInterest" one place and "calculateCompoundInterest" in another. That was
       MY typo.
       I sympathize with "Anonymous User - Nov. 13, 2002" -- this book is SLOPPY. Guido isn't sloppy...

       The fact that users are adding fixes is great, but wouldn't it be great if the energy was going into helping
       at a higher level than fixing typos?
       There's a lot to be said for the process of conventional publishing if it leads to examples that work "first
       time, every time."