[Zope] Newbie Q: How do I cal ZPT objects from a python script
object?
J Cameron Cooper
zope-l at jcameroncooper.com
Mon Dec 6 14:41:28 EST 2004
Joe Block wrote:
> I'm running Zope 2.6.3 on Mac OS 10.3.6 (installed via fink).
>
> I'm trying to call a very simple page template from inside a python
> script object to display a message (in this case, the results of a
> database insert).
>
> Here's my results page template:
> <html>
> <head>
> <title tal:content="template/title">The title</title>
> <style type="text/css">
> @import "/octavo/css/style.css";
> </style>
> </head>
> <body>
>
> <p><span tal:replace="request/msg">msg</span></p>
>
> <div align="center">
> <p>Logged in as <span tal:content="user/getUserName">User</span></p>
> </div>
> </body>
> </html>
>
> If I type the template's URL into a browser
> (<http://athena.local.:8080/octavo/trackart/results?
> msg=Foo%20bar%20baz>), it displays Foo bar baz as expected. I just
> can't call the template from within my python script, when I try I get
> the following error message
>
> Zope Error
>
> Zope has encountered an error while publishing this resource.
>
> Error Type: KeyError
> Error Value: msg
>
> I'm calling it from within the script object like so:
>
> msg = '%s added to client %s' % (job_id, clientname)
> return container.results(msg = msg)
>
> The script is in the same folder as the results template.
>
> I know there has to be something simple I'm missing, but I've banged my
> head against the wall for a while and haven't made any progress.
Call parameters come from 'options'. Make your TALES statement be
request/msg | options/msg | default
where 'default' is what you want to happen if no message is given
--jcc
More information about the Zope
mailing list