~azzar1/unity/add-show-desktop-key

« back to all changes in this revision

Viewing changes to www/common/interpret.py

  • Committer: mattgiuca
  • Date: 2008-01-18 05:20:01 UTC
  • Revision ID: svn-v3-trunk0:2b9c9e99-6f39-0410-b283-7f802c844ae2:trunk:247
request.py: Added get_cgi_environ method. This asks Apache to emulate CGI
environment vars.
debuginfo: Uses get_cgi_environ instead of hackishly making its own.
interpret.py: Now uses get_cgi_environ to set up the CGI environment, and then
restores the existing environment.

Show diffs side-by-side

added added

removed removed

Lines of Context:
117
117
        f.flush()
118
118
        f.seek(0)       # Rewind, for reading
119
119
 
 
120
    # Set up the environment
 
121
    # This automatically asks mod_python to load up the CGI variables into the
 
122
    # environment (which is a good first approximation)
 
123
    old_env = os.environ.copy()
 
124
    for k in os.environ.keys():
 
125
        del os.environ[k]
 
126
    for (k,v) in req.get_cgi_environ().items():
 
127
        os.environ[k] = v
 
128
 
120
129
    # usage: tramp uid jail_dir working_dir script_path
121
130
    pid = subprocess.Popen(
122
131
        [trampoline, str(uid), jail_dir, working_dir, interpreter,
124
133
        stdin=f, stdout=subprocess.PIPE, stderr=subprocess.STDOUT,
125
134
        cwd=tramp_dir)
126
135
 
 
136
    # Restore the environment
 
137
    for k in os.environ.keys():
 
138
        del os.environ[k]
 
139
    for (k,v) in old_env.items():
 
140
        os.environ[k] = v
 
141
 
127
142
    # process_cgi_line: Reads a single line of CGI output and processes it.
128
143
    # Prints to req, and also does fancy HTML warnings if Content-Type
129
144
    # omitted.