RE: [Zope] how to call an external module from a Python script?
From: Dieter Maurer *EXTERN* [mailto:dieter@handshake.de]
And how do I call a DTML-variable (object?) defined with <dtml-let var=...> from my script? context.var, container.var, script.var don't work. You bind the "namespace". This binding is there for precisely this aim....
From the Zope Book (Chapter 8, binding variables):
Namespace ... If your script is calles from a DTML Method, and you have chosen a name for this binding, then the named variable contains the DTML namespace ...
... these bindings are listed in comments at the top of your script files:
... ##bind namespace= ...
You can change your script's bindings by changing these comments...
My script: ... ##bind namespace=namespace ... zone = namespace.zone return zone It is called from a DTML-method where the tag <dtml-var zone> is rendered correctly: ... <dtml-var get_status_a> ... Error: Zope Error Zope has encountered an error while publishing this resource. Error Type: AttributeError Error Value: zone
Reif Peter writes:
... My script:
... ##bind namespace=namespace ...
zone = namespace.zone return zone
It is called from a DTML-method where the tag <dtml-var zone> is rendered correctly:
... <dtml-var get_status_a> ...
Error:
Zope Error Zope has encountered an error while publishing this resource. Error Type: AttributeError Error Value: zone How is it called?
Implicitly (<dtml-var myPythonScript>) or explicitly? In the second case, you must pass the namespace yourself! In the first case, check in the binding tab that the binding really took place. PythonScripts are quite picky with the binding comments at their start. A minor typo and part of the comments are no longer recognized. Dieter
From a newbie to all the Zope community I have to say - thanks for the documentation! I've been trudging through it all morning trying to learn this namespace stuff. Thanks to Dieter and the information below, I think I was finally able to do what I wanted. I created a script that does a ZopeFind on a certain segment of my tree to find one document. So, calling it like this returns the document, just like I want:
<dtml-var "findProcedure('My Procedure')"> That's because I'm returning a DTML Document object and dtml-var seems to like that. My question (probably easy but I can't get it, nonetheless) - how can I put that in a link? I try this: <a href="../findProcedure?procName='My Procedure'">Get Procedure</a> Which should find it but I think since it's returning the object itself and not the "rendered" HTML, it doesn't work. Should this be working or am I doing something wrong?? Thanks for your help! Andy On Tue, 25 Sep 2001, Dieter Maurer wrote:
Reif Peter writes:
... My script:
... ##bind namespace=namespace ...
zone = namespace.zone return zone
It is called from a DTML-method where the tag <dtml-var zone> is rendered correctly:
... <dtml-var get_status_a> ...
Error:
Zope Error Zope has encountered an error while publishing this resource. Error Type: AttributeError Error Value: zone How is it called?
Implicitly (<dtml-var myPythonScript>) or explicitly?
In the second case, you must pass the namespace yourself! In the first case, check in the binding tab that the binding really took place.
PythonScripts are quite picky with the binding comments at their start. A minor typo and part of the comments are no longer recognized.
Dieter
_______________________________________________ Zope maillist - Zope@zope.org http://lists.zope.org/mailman/listinfo/zope ** No cross posts or HTML encoding! ** (Related lists - http://lists.zope.org/mailman/listinfo/zope-announce http://lists.zope.org/mailman/listinfo/zope-dev )
participants (3)
-
Andy Jewell -
Dieter Maurer -
Reif Peter