[ZPT] How to translate <dtml-call MyMethod> little correction

Damir Bartakovic damir@stud.fbi.fh-darmstadt.de
Wed, 23 Jan 2002 21:50:45 +0100 (CET)


Hi guys,

thanks for the hints.
Unfortunately it didn't work at first like you suggested.
I had to change the script to following:

 R = context.REQUEST

 if R.form["submit"] == 'Insert':
   context.InsertMethod(R)
   print 'Your data was inserted!'
 else:
   print 'No Insert'

return printed


If I used R.form.submit I got the attached error message.
Like it seems REQUEST.form is a dictionary and cannot be accessed like a
object???
I am not a specialist so correct me if I am wrong.

cheers
Damir

  <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: Result)
  File /usr/local/Zope-2.5.0b2/lib/python/ZPublisher/Publish.py, line 40,
in call_object
    (Object: Result)
  File /usr/local/Zope-2.5.0b2/lib/python/Shared/DC/Scripts/Bindings.py,
line 252, in __call__
    (Object: Result)
  File /usr/local/Zope-2.5.0b2/lib/python/Shared/DC/Scripts/Bindings.py,
line 283, in _bindAndExec
    (Object: Result)
  File
/usr/local/Zope-2.5.0b2/lib/python/Products/PageTemplates/ZopePageTemplate
.py, line 203, in _exec
    (Object: Result)
  File
/usr/local/Zope-2.5.0b2/lib/python/Products/PageTemplates/PageTemplate.py,
line 85, in pt_render
    (Object: Result)
  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 432,
in do_insertStructure_tal
  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/Expressions.py,
line 153, in __call__
  File
/usr/local/Zope-2.5.0b2/lib/python/Products/PageTemplates/Expressions.py,
line 150, in _eval
    (Info: here)
  File
/usr/local/Zope-2.5.0b2/lib/python/Products/PageTemplates/Expressions.py,
line 75, in render
    (Object: Result_fetch)
  File
/usr/local/Zope-2.5.0b2/lib/python/Products/PageTemplates/ZRPythonExpr.py,
line 75, in call_with_ns
    (Object: __render_with_namespace__)
  File /usr/local/Zope-2.5.0b2/lib/python/Shared/DC/Scripts/Bindings.py,
line 266, in __render_with_namespace__
    (Object: Result_fetch)
  File /usr/local/Zope-2.5.0b2/lib/python/Shared/DC/Scripts/Bindings.py,
line 283, in _bindAndExec
    (Object: Result_fetch)
  File
/usr/local/Zope-2.5.0b2/lib/python/Products/PythonScripts/PythonScript.py,
line 291, in _exec
    (Object: Result_fetch)
    (Info: ({'script': &lt;PythonScript instance at 8aecba0&gt;,
'context': &lt;TransparentFolder instance at 8d54670&gt;, 'container':
&lt;TransparentFolder instance at 8d54670&gt;, 'traverse_subpath': []},
(), {}, None))
  File Script (Python), line 5, in Result_fetch
    (Object: guarded_getattr)
  File /usr/local/Zope-2.5.0b2/lib/python/AccessControl/ZopeGuards.py,
line 47, in guarded_getattr
TALESError: Sorry, an error occurred



-----Original Message-----
From: Evan Simpson [mailto:evan@zope.com]
Sent: Mittwoch, 23. Januar 2002 18:38
To: jpeterso@rangebroadband.com
Cc: Damir Bartakovic; zpt@zope.org
Subject: Re: [ZPT] How to translate <dtml-call MyMethod> to ZPT

Jeff Peterson wrote:
> Create a python script:
>
> doInsert:
>
> R = context.REQUEST
>
> if R.form.submit == 'Insert':
>   context.InsertMethod(R)
>   print 'Your data was inserted!'
> else:
>   print 'No Insert'
>
> return printed

This is fine.

> then in ZPT do:
>
> <div tal:content="python: doInsert()"/>Insert yes/no?</div>

This should be:

<span tal:content="here/doInsert">Insert yes/no?</span>

Cheers,

Evan @ Zope