Newbie Q: How do I cal ZPT objects from a python script object?
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. jpb -- Joe Block <jpb@ApesSeekingKnowledge.net> Computer Science is about lofty design goals and algorithmic optimization. System Administration is about cleaning up the resulting mess.
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
On Dec 6, 2004, at 2:41 PM, J Cameron Cooper wrote:
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
Thanks, that fixed it. jpb -- Joe Block <jpb@ApesSeekingKnowledge.net> As nightfall does not come at once, neither does oppression. In both instances, there is a twilight when everything remains seemingly unchanged. And it is in such twilight that we all must be most aware of change in the air--however slight--lest we become unwitting victims of the darkness. -- Justice William O. Douglas
participants (2)
-
J Cameron Cooper -
Joe Block