[mod_python] BUG IN cgihandler / setup_cgi

Gregory (Grisha) Trubetskoy grisha at modpython.org
Mon Mar 11 14:13:19 EST 2002


This is clearly a booboo, thanks Andre for pointing it out. I'll make sure
to patch it up in cvs.

On Mon, 11 Mar 2002, Andre Reitz wrote:

> def setup_cgi(req):
>     """
>     Replace sys.stdin and stdout with an objects that read/write to
>     the socket, as well as substitute the os.environ.
>     Returns (environ, stdin, stdout) which you must save and then use
>     with restore_nocgi().
>     """
>
>     # save env
>     env = os.environ.copy() <<<< 1 !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
>
>     si = sys.stdin
>     so = sys.stdout
>
>     env = build_cgi_env(req) <<<<< 2 !!!!!!!!!!!!!!!!!!!
>
>     for k in env.keys():
>         os.environ[k] = env[k]
>
>     sys.stdout = CGIStdout(req)
>     sys.stdin = CGIStdin(req)
>
>     sys.argv = [] # keeps cgi.py happy
>
>     return env, si, so <<<< 3 !!!!!!!!!!!!!!!!!!!!!!!!!
>
>
> - The env (1) perhaps should be called originalenv
> - (2) keep as is
> - (3) change to: return originalenv, si, so
>
>
> Will somebody patch it?
>
> This can cause critical bugs!
>
> Greetings, Andre'
>
> --
> _____________________________________________
> inworks GmbH            Andre Reitz
> Magirusstrasse 44       Tel. 0731/93 80 7-21
> 89077 Ulm               http://www.inworks.de
>
>




More information about the Mod_python mailing list