On Thursday 05 June à 14:05, Simon Forster wrote:
On Thursday, June 5, 2003, at 01:51 pm, Sylvain Thénault wrote:
<span tal:content="request/form/years">2</span>
Thank you for that. That fixes one problem but then:
$<span tal:content="python: here.calculateCompoundingInterest(principal, interest_rate, periods, years)" >1.00</span>
fails (as I would expect given your posting) but so does
<span tal:content="python: here.calculateCompoundingInterest(request/form/principal, request/form/interest_rate, request/form/periods, request/form/years)" >1.00</span>
with error:
Error Type: NameError Error Value: global name 'form' is not defined
while
<span tal:content="python: here.calculateCompoundingInterest(request/principal, request/interest_rate, request/periods, request/years)" >1.00</span>
fails with error
Error Type: NameError Error Value: global name 'principal' is not defined
Why?
you can not access fields in the same way in the python: expression as in others TALES expressions. In a python expression, you can access form fields by using : request.form['years'] I suggest you to look at the page template reference [1] before the end of the book ;-) [1] http://www.zope.org/Documentation/Books/ZopeBook/current/AppendixC.stx -- Sylvain Thénault LOGILAB, Paris (France). http://www.logilab.com http://www.logilab.fr http://www.logilab.org