[Zope-CMF] Problem with Example in The Zope Book

mcolli@SyscomCipher.com.ar mcolli@SyscomCipher.com.ar
Tue, 2 Jul 2002 12:21:40 -0300


Hi,

I am following the Zope Book and I am trying to reproduce an example using
two Page Templates and a Python Script and I get the following error:

====================================
Zope Error
Zope has encountered an error while publishing this resource.

Error Type: Undefined
Error Value: years not found in 'years', at line 4, column 1



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

Troubleshooting Suggestions

The URL may be incorrect.
The parameters passed to this resource may be incorrect.
A resource that this resource relies on may be encountering an error.
For more detailed information about the error, please refer to the HTML
source for this page.

If the error persists please contact the site maintainer. Thank you for
your patience.




Traceback (innermost last):
  File C:\Program Files\Zope\lib\python\ZPublisher\Publish.py, line 150, in
publish_module
  File C:\Program Files\Zope\lib\python\ZPublisher\Publish.py, line 114, in
publish
  File C:\Program Files\Zope\lib\python\Zope\__init__.py, line 159, in
zpublisher_exception_hook
    (Object: Sales)
  File C:\Program Files\Zope\lib\python\ZPublisher\Publish.py, line 98, in
publish
  File C:\Program Files\Zope\lib\python\ZPublisher\mapply.py, line 88, in
mapply
    (Object: interestRateDisplay)
  File C:\Program Files\Zope\lib\python\ZPublisher\Publish.py, line 39, in
call_object
    (Object: interestRateDisplay)
  File C:\Program Files\Zope\lib\python\Shared\DC\Scripts\Bindings.py, line
252, in __call__
    (Object: interestRateDisplay)
  File C:\Program Files\Zope\lib\python\Shared\DC\Scripts\Bindings.py, line
283, in _bindAndExec
    (Object: interestRateDisplay)
  File C:\Program
Files\Zope\lib\python\Products\PageTemplates\ZopePageTemplate.py, line 210,
in _exec
    (Object: interestRateDisplay)
  File C:\Program
Files\Zope\lib\python\Products\PageTemplates\PageTemplate.py, line 86, in
pt_render
    (Object: interestRateDisplay)
    (Info: {'container': <Folder instance at 01A900D0>,
 'here': <Folder instance at 01A900D0>,
 'modules': <Products.PageTemplates.ZRPythonExpr._SecureModuleImporter
instance at 010A88CC>,
 'nothing': None,
 'options': {'args': ()},
 'request': <h3>form</h3><table><tr valign="top" align
="left"><th>principal</th><td>7.0</td></tr><tr valign="top" align
="left"><th>periods</th><td>4</td></tr><tr valign="top" align
="left"><th>interest_rate</th><td>1.0</td></tr><tr valign="top" align
="left"><th>years</th><td>5</td></tr></table><h3>cookies</h3><table><tr
valign="top" align
="left"><th>tree-s</th><td>'eJyLjlZ3hANPW/XYWAAtiQTP'</td></tr></table><h3>lazy

items</h3><table><tr valign="top" align="left"><th>SESSION</th><td>
&lt;Python Method object at
01A99660&gt;</td></tr></table><h3>other</h3><table><tr valign="top" align
="left"><th>principal</th><td>7.0</td></tr><tr valign="top" align
="left"><th>URL1</th><td>'http://127.0.0.1:8080/Sales'</td></tr><tr valign
="top" align="left"><th>PUBLISHED</th><td>&lt;ZopePageTemplate instance at
0223F3D0&gt;</td></tr><tr valign="top" align
="left"><th>periods</th><td>4</td></tr><tr valign="top" align
="left"><th>tree-s</th><td>'eJyLjlZ3hANPW/XYWAAtiQTP'</td></tr><tr valign
="top" align
="left"><th>BASE3</th><td>'http://127.0.0.1:8080/Sales/interestRateDisplay'</td></tr><tr

valign="top" align
="left"><th>URL2</th><td>'http://127.0.0.1:8080'</td></tr><tr valign="top"
align="left"><th>BASE1</th><td>'http://127.0.0.1:8080'</td></tr><tr valign
="top" align="left"><th>traverse_subpath</th><td>[]</td></tr><tr valign
="top" align="left"><th>years</th><td>5</td></tr><tr valign="top" align
="left"><th>URL0</th><td>'http://127.0.0.1:8080/Sales/interestRateDisplay'</td></tr><tr

valign="top" align
="left"><th>SERVER_URL</th><td>'http://127.0.0.1:8080'</td></tr><tr valign
="top" align="left"><th>interest_rate</th><td>1.0</td></tr><tr valign="top"
align
="left"><th>URL</th><td>'http://127.0.0.1:8080/Sales/interestRateDisplay'</td></tr><tr

valign="top" align
="left"><th>AUTHENTICATED_USER</th><td>mcolli</td></tr><tr valign="top"
align="left"><th>BASE2</th><td>'http://127.0.0.1:8080/Sales'</td></tr><tr
valign="top" align="left"><th>TraversalRequestNameStack</th><td>
[]</td></tr><tr valign="top" align
="left"><th>AUTHENTICATION_PATH</th><td>''</td></tr><tr valign="top" align
="left"><th>BASE0</th><td>'http://127.0.0.1:8080'</td></tr><tr valign="top"
align
="left"><th>URL0</th><td>http://127.0.0.1:8080/Sales/interestRateDisplay</td></tr><tr

valign="top" align
="left"><th>URL1</th><td>http://127.0.0.1:8080/Sales</td></tr><tr valign
="top" align="left"><th>URL2</th><td>http://127.0.0.1:8080</td></tr><tr
valign="top" align
="left"><th>BASE0</th><td>http://127.0.0.1:8080</td></tr><tr valign="top"
align="left"><th>BASE1</th><td>http://127.0.0.1:8080</td></tr><tr valign
="top" align
="left"><th>BASE2</th><td>http://127.0.0.1:8080/Sales</td></tr><tr valign
="top" align
="left"><th>BASE3</th><td>http://127.0.0.1:8080/Sales/interestRateDisplay</td></tr></table><h3>environ</h3><table><tr

valign="top" align="left"><th>HTTP_ACCEPT_ENCODING</th><td>'gzip,
deflate'</td></tr><tr valign="top" align
="left"><th>CONTENT_TYPE</th><td>'application/x-www-form-urlencoded'</td></tr><tr

valign="top" align="left"><th>PATH_TRANSLATED</th><td>'
\\Sales\\interestRateDisplay'</td></tr><tr valign="top" align
="left"><th>HTTP_ACCEPT</th><td>'image/gif, image/x-xbitmap, image/jpeg,
image/pjpeg, application/vnd.ms-powerpoint, application/vnd.ms-excel,
application/msword, */*'</td></tr><tr valign="top" align
="left"><th>HTTP_COOKIE</th><td>'tree-s
="eJyLjlZ3hANPW/XYWAAtiQTP"'</td></tr><tr valign="top" align
="left"><th>HTTP_ACCEPT_LANGUAGE</th><td>'es-ar'</td></tr><tr valign="top"
align="left"><th>GATEWAY_INTERFACE</th><td>'CGI/1.1'</td></tr><tr valign
="top" align="left"><th>SERVER_PORT</th><td>'8080'</td></tr><tr valign
="top" align="left"><th>HTTP_USER_AGENT</th><td>'Mozilla/4.0 (compatible;
MSIE 5.0; Windows 95; DigExt)'</td></tr><tr valign="top" align
="left"><th>CONTENT_LENGTH</th><td>'73'</td></tr><tr valign="top" align
="left"><th>REMOTE_ADDR</th><td>'127.0.0.1'</td></tr><tr valign="top" align
="left"><th>channel.creation_time</th><td>1025622764</td></tr><tr valign
="top" align="left"><th>SERVER_PROTOCOL</th><td>'HTTP/1.1'</td></tr><tr
valign="top" align="left"><th>PATH_INFO</th><td>'/Sales/interestRateDi
splay'</td></tr><tr valign="top" align
="left"><th>HTTP_HOST</th><td>'127.0.0.1:8080'</td></tr><tr valign="top"
align="left"><th>REQUEST_METHOD</th><td>'POST'</td></tr><tr valign="top"
align="left"><th>SCRIPT_NAME</th><td>''</td></tr><tr valign="top" align
="left"><th>SERVER_SOFTWARE</th><td>'Zope/(Zope 2.5.1 (binary release,
python 2.1, win32-x86), python 2.1.3, win32) ZServer/1.1b1'</td></tr><tr
valign="top" align
="left"><th>CONNECTION_TYPE</th><td>'Keep-Alive'</td></tr><tr valign="top"
align
="left"><th>HTTP_REFERER</th><td>'http://127.0.0.1:8080/Sales/interestRateForm'</td></tr><tr

valign="top" align
="left"><th>SERVER_NAME</th><td>'ibm1.syscom.com'</td></tr></table>,
 'root': <Application instance at 01A90880>,
 'template': <ZopePageTemplate instance at 0223F3D0>,
 'traverse_subpath': [],
 'user': mcolli})
  File C:\Program Files\Zope\lib\python\TAL\TALInterpreter.py, line 158, in
__call__
  File C:\Program Files\Zope\lib\python\TAL\TALInterpreter.py, line 191, in
interpret
  File C:\Program Files\Zope\lib\python\TAL\TALInterpreter.py, line 413, in
do_insertText_tal
  File C:\Program Files\Zope\lib\python\Products\PageTemplates\TALES.py,
line 265, in evaluateText
  File C:\Program Files\Zope\lib\python\Products\PageTemplates\TALES.py,
line 247, in evaluate
  File C:\Program
Files\Zope\lib\python\Products\PageTemplates\Expressions.py, line 198, in
__call__
  File C:\Program
Files\Zope\lib\python\Products\PageTemplates\Expressions.py, line 188, in
_eval
Undefined: (see above)

==============================
The sources of the template pages and the python scripts are as follows:

interestRateForm:

<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>

=============================
# Script (Python) "calculateCompoundingInterest"
# parameters=principal, interest_rate, periods, years
#
"""
Calculate Compounding Interest.
"""
i = interest_rate / periods
n = periods * years
return ((1 + i) ** n) * principal
=============================

and interestRateDisplay:
===========================

<html>
  <body>
  <p>Your total balance (or debt) including compounded interest over
<span tal:content="years">2</span> years is:</p>
<p><b>$<span tal:content="python: here.calculateCompoundingInterest
(principal, interest_rate, periods, years)" >1.00</span></b></p>
  </body>
</html>

============================

As you can see, I am learning this and I can not understand why I get this
error. Could you help me?

Many thanks
Regards
Mariela