Newbie can't get ZB Ch3 example to work
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
Hi Linda, I'll look into this, the first obvious problem is that I didn't test it when I wrote it <duck>. The next obvious problem is that the input form is wrong. I'll fix it, test it, upload it to the site, and then get back to you and the list. -Michel On Fri, 23 Feb 2001, Linda Timberlake wrote:
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
_______________________________________________ Zope maillist - Zope@zope.org http://lists.zope.org/mailman/listinfo/zope ** No cross posts or HTML encoding! ** (Related lists - http://lists.zope.org/mailman/listinfo/zope-announce http://lists.zope.org/mailman/listinfo/zope-dev )
participants (2)
-
Linda Timberlake -
Michel Pelletier