[ZPT] Parameter to a python script?

Damir Bartakovic damir@stud.fbi.fh-darmstadt.de
Fri, 25 Jan 2002 14:44:35 +0100


Hi there,

Two questions:
1)
I want to give some parameters to a python script. I read the Tutorial Part
4 --> using scripts.

Therefore I am calling
<span tal:replace="python: here.display_sex(result.pers_sex)"></span>
but I get the attached error-message.

I tried calling the script without parameters <span tal:replace="python:
here.display_sex()"></span> which works.
Also just the parameters <span tal:replace="python: result.pers_sex"></span>
which works too.
What I am doing wrong?

2)
Since I am not very common with python and scripts. In which way I can
access the variable within the script?
Is there something like argv[0] or can I use just the parameter name
pers_sex within the script?

kind regard
Damir


<TD WIDTH="90%">
  <H2>Site Error</H2>
  <P>An error was encountered while publishing this resource.
  </P>
  <P><STRONG>TALESError</STRONG></P>

  Sorry, a site error occurred.<p>
<pre
          onclick="this.firstChild.data=this.lastChild.data">
        &sect;<!--
Traceback (innermost last):
  File /usr/local/Zope-2.5.0b2/lib/python/ZPublisher/Publish.py, line 151,
in publish_module
  File /usr/local/Zope-2.5.0b2/lib/python/ZPublisher/Publish.py, line 115,
in publish
  File /usr/local/Zope-2.5.0b2/lib/python/Zope/__init__.py, line 158, in
zpublisher_exception_hook
    (Object: Contacts)
  File /usr/local/Zope-2.5.0b2/lib/python/ZPublisher/Publish.py, line 99, in
publish
  File /usr/local/Zope-2.5.0b2/lib/python/ZPublisher/mapply.py, line 88, in
mapply
    (Object: SearchReport)
  File /usr/local/Zope-2.5.0b2/lib/python/ZPublisher/Publish.py, line 40, in
call_object
    (Object: SearchReport)
  File /usr/local/Zope-2.5.0b2/lib/python/Shared/DC/Scripts/Bindings.py,
line 252, in __call__
    (Object: SearchReport)
  File /usr/local/Zope-2.5.0b2/lib/python/Shared/DC/Scripts/Bindings.py,
line 283, in _bindAndExec
    (Object: SearchReport)
  File
/usr/local/Zope-2.5.0b2/lib/python/Products/PageTemplates/ZopePageTemplate.p
y, line 203, in _exec
    (Object: SearchReport)
  File
/usr/local/Zope-2.5.0b2/lib/python/Products/PageTemplates/PageTemplate.py,
line 85, in pt_render
    (Object: SearchReport)
  File /usr/local/Zope-2.5.0b2/lib/python/TAL/TALInterpreter.py, line 158,
in __call__
  File /usr/local/Zope-2.5.0b2/lib/python/TAL/TALInterpreter.py, line 191,
in interpret
  File /usr/local/Zope-2.5.0b2/lib/python/TAL/TALInterpreter.py, line 523,
in do_useMacro
  File /usr/local/Zope-2.5.0b2/lib/python/TAL/TALInterpreter.py, line 191,
in interpret
  File /usr/local/Zope-2.5.0b2/lib/python/TAL/TALInterpreter.py, line 542,
in do_defineSlot
  File /usr/local/Zope-2.5.0b2/lib/python/TAL/TALInterpreter.py, line 191,
in interpret
  File /usr/local/Zope-2.5.0b2/lib/python/TAL/TALInterpreter.py, line 476,
in do_loop_tal
  File /usr/local/Zope-2.5.0b2/lib/python/TAL/TALInterpreter.py, line 191,
in interpret
  File /usr/local/Zope-2.5.0b2/lib/python/TAL/TALInterpreter.py, line 491,
in do_condition
  File /usr/local/Zope-2.5.0b2/lib/python/TAL/TALInterpreter.py, line 191,
in interpret
  File /usr/local/Zope-2.5.0b2/lib/python/TAL/TALInterpreter.py, line 413,
in do_insertText_tal
  File /usr/local/Zope-2.5.0b2/lib/python/Products/PageTemplates/TALES.py,
line 269, in evaluateText
  File /usr/local/Zope-2.5.0b2/lib/python/Products/PageTemplates/TALES.py,
line 247, in evaluate
  File
/usr/local/Zope-2.5.0b2/lib/python/Products/PageTemplates/ZRPythonExpr.py,
line 49, in __call__
    (Info: here.display_sex(result.pers_sex))
  File Python expression &quot;here.display_sex(result.pers_sex)&quot;, line
2, in f
    (Object: guarded_getattr)
  File /usr/local/Zope-2.5.0b2/lib/python/Shared/DC/Scripts/Bindings.py,
line 252, in __call__
    (Object: display_sex)
  File /usr/local/Zope-2.5.0b2/lib/python/Shared/DC/Scripts/Bindings.py,
line 283, in _bindAndExec
    (Object: display_sex)
  File
/usr/local/Zope-2.5.0b2/lib/python/Products/PythonScripts/PythonScript.py,
line 291, in _exec
    (Object: display_sex)
    (Info: ({'script': &lt;PythonScript instance at 9f3bb58&gt;, 'context':
&lt;TransparentFolder instance at 8ed0370&gt;, 'container': &lt;Folder
instance at 8adefa0&gt;, 'traverse_subpath': []}, (0,), {}, None))
TALESError: Sorry, an error occurred