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

webmaster@zope.org webmaster@zope.org
Thu, 28 Nov 2002 02:17:45 -0500


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

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

    This form collects information and calls the *interestRateDisplay*
    template.  Now, create a Python-based script called
    *calculateCompoundingInterest* that accepts four parameters,
    "principal", "interest_rate", "periods" and "years" with the
    following python code::

      ## Script (Python) "calculateCompoundInterest"
      ##parameters=principal, interest_rate, periods, years
      ##
      """ 
      Calculate compounding interest.
      """
      i = interest_rate / periods
      n = periods * years
      return ((1 + i) ** n) * principal 

      % Anonymous User - July 25, 2002 4:25 pm:
       Urgent!!!

       I did exactly as instructed here. However, I got "Error Type: Undefined
        Error Value: years not found in 'years', at line 5, column 3
       ." It seems that Python script is not getting the parm "years." Anybody knows why?

      % Anonymous User - July 27, 2002 1:24 pm:
       I had the same problem. Solved by hacking not by science :(
       I change the variable 'years' to 'yrs' and it worked.
       Maybe the illuminati founding fathers can shed some light...

      % Anonymous User - July 27, 2002 2:50 pm:
       Apologize for the previous information – had the page in the cache – 
       It does not work!

      % Anonymous User - Aug. 13, 2002 3:49 am:
       I'm having the same problem but I don't think the problem is in the python script I think its in the
       interestRateDisplay file. I wonder if I'm having this problem because I'm running win98.

      % Anonymous User - Aug. 28, 2002 7:35 pm:
       Don't forget to enter param names into the Parameter List field  on the script edit form 
       (it should look like  

       Parameter List [principal, interest_rate, periods, years]

       where [ and ] mean the boundaries of entry box

      % Anonymous User - Sep. 21, 2002 2:52 pm:
       Are the "##" lines convention or do they carry any semantic significance?

      % Anonymous User - Nov. 18, 2002 2:58 pm:
       I am rather disappointed in this example. It required me to put in lines converting the parameters from
       strings to numbers. It seems that the form tags regarding variable types are being ignored.

      % Anonymous User - Nov. 28, 2002 2:17 am:
       When I go to edit the python script document or whatever document, I always get the initial text that comes
       when we create any document, but not the changed text/code. But when I view it, it shows the saved text.Does
       any one know why??