[Zope] Passing context from DTML to Python

Dylan Reinhardt zope@dylanreinhardt.com
11 Jul 2003 15:36:53 -0700


There's hardly anything to do, really.  Context is passed for you.

If you have method A and script B in your root, a URL of the form:

http://yourserver/path/to/subfolder/A

will call A *in the context* of the path you specified.*  If A calls B,
then B will have the same context by default.  Ta da!

The fact that B is stored in the same folder as A is only relevant to
how A *finds* B, not to what context B runs in. For more detail, see the
Acquisition chapter of the Zope Book:
http://www.zope.org/Documentation/Books/ZopeBook/2_6Edition

HTH,

Dylan


{*} - Assuming, of course, that there is no other object called A that
would be acquired first.  :-)



On Fri, 2003-07-11 at 14:13, Martin Richtarsky wrote:
> Hi,
> 
> I have an DTML document (doc) and a Python Script (script).
> Both of these are stored in the root folder. Now, I want to
> call doc on some arbitrary subfolder. doc outputs standard_html_header
> etc. and passes control to the script to do the processing. The problem is,
> 'context' in the script is the folder where the caller, i.e. the DTML
> document, is in. But I want to do work on the objects in the folder
> doc was called on.
> 
> I would use something like:
> <dtml-var expr="pythonscript(context)">
> but of course there is no context within DTML.
> 
> Any hints? The documentation didn't help me.
> 
> Thanks,
> Martin