[mod_python] namespace available to psp

Jim Gallacher jpg at jgassociates.ca
Thu May 18 12:19:24 EDT 2006


David Bear wrote:
> When using psp called from publisher, what is the namespace shared
> between the instance of publisher and the called psp?
> 
> I modelled a test of the templating example from modpython.org. 
> 
> I have a function call _any_page that is called to setup any/all
> objects passed to a psp page.
> 
> in that function I have 
> 
> vars = {"mytest": "this is  atest"}
> 
> then, in my psp page I have
> 
> <%= mytest %>
> 
> When run, ie. when called from the publisher script I get a Namerror
> exception -- that mytest is not defined.
> 
> so then I tried
> 
> <%= locals() %> in the psp page and looked at the namespace. I didn't
> see any of the vars defined in the publisher script.
> 

You are passing in vars in the PSP() constructor or in the run() method, 
right?

tmpl = psp.PSP(req, filename=filename, vars=vars)
or
tmpl.run(vars)

Jim




More information about the Mod_python mailing list