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

webmaster@zope.org webmaster@zope.org
Tue, 31 Dec 2002 09:46:29 -0500


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

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

    For this example, you will need two page templates named
    *interestRateForm* and *interestRateDisplay* to collect the
    information from the user and display it, respectively.  You will
    also need a Python-based script called
    *calculateCompoundingInterest* that will do the actual
    calculation.  The first step is to create a web form in
    *interestRateForm* that collects "principal", "interest_rate",
    "periods" and "years" from your users.  Here's an example
    *interestRateForm* page templates::

      <html>
        <body>

        <form action="interestRateDisplay" method="POST">
        <p>Please enter the following information:</p>

        Your current balance (or debt): <input name="principal:float"><br>
        Your annual interest rate: <input name="interest_rate:float"><br>
        Number of periods in a year: <input name="periods:int"><br>
        Number of years: <input name="years:int"><br>
        <input type="submit" value=" Calculate "><br>
        </form>

        </body>
      </html>

      % Anonymous User - June 5, 2002 5:22 am:
       I had to name my template as interestRateForm_html before Zope 2.4.0 will allow it to be displayed without
       errors.

      % Anonymous User - July 4, 2002 9:30 pm:
       How about:
       i = interest_rate / (100 * periods)
       n = periods * years
       return ((1 + i) ** n) * principal

      % Saman - Nov. 12, 2002 7:18 am:
       I get the folowing error:
       Error Type: KeyError
       Error Value: years
       can enybody help
       thank you

      % Anonymous User - Dec. 31, 2002 9:46 am:
       I encountered the same error.  Any help?