[mod_python] from mod_python import apache

Iker Arizmendi iker at research.att.com
Thu Aug 19 23:11:58 EDT 2004


Declaring variables as global within a function
definition seems to be a syntax error. But even if
I moved the declarations to module scope the global
variable in the importing module is still not visible
in the module that is imported (which seems reasonable,
otherwise modules would risk polluting the namespace
of modules they imported).


Nic Ferrier wrote:

> How about:
> 
> 
> req_object = None
> 
> def handler(req):
>         global req_object
>         req_object = req
>         make_some_call()
>         return None
> 
> def make_some_call():
>         global req_object
>         req_object.content_type = "text/plain"
>         return None
> 
> 
> 

-- 
Iker Arizmendi
AT&T Labs - Research
Speech and Image Processing Lab
e: iker at research.att.com
w: http://research.att.com




More information about the Mod_python mailing list