[Zope] Newbie can't get ZB Ch3 example to work

Linda Timberlake Linda.Timberlake@sas.com
Fri, 23 Feb 2001 13:07:17 -0500


Hi,
I'm new to Zope and am working through the Zope book examples.  I'm stuck on the compound interest rates example, found  in Chapter 3 under the "Using Scripts" section.   I can't get the python script in that example to work, using Zope 2.3.0.

I copied the entire example into Zope and tried to exercise it by going to the "View" tab on the interestRateForm DTML method.  I typed in valid integers for the 4 parameters and pressed the "Calculate" button.  I got:
ErrorType: TypeError
Error Value: not enough arguments; expected 4, got 0

So, to simplify, I went directly to the Python script "calculateCompoundingInterest" , added string.atoi lines to avoid "can't multiply sequence with non-int" type errors on input, and tried to run the script directly via the "Test" tab.  Now I get:
Error Type: TypeError
Error Value: not enough arguments; expected 4, got 3

Here's my python script (I do have the 4 parameters separated by commas in the script's "Parameter list" area):

"""
Calculate compounding interest.  Accepts four parameters, 
"principal", "interest rate", "periods" and "years".
"""
# I added the next 5 lines so could test this script directly via Test tab.
import string
principal=string.atoi(principal)
interest_rate=string.atoi(interest_rate)
years=string.atoi(years)
periods=string.atoi(periods)
i = periods * interest_rate
i = i + 1
n= periods * years
return pow((1+i), n) * principal


Thanks for any help.
-Linda