MCPcopy
hub / github.com/cherrypy/cherrypy / handler

Function handler

cherrypy/_cpmodpy.py:142–250  ·  view source on GitHub ↗
(req)

Source from the content-addressed store, hash-verified

140
141
142def handler(req):
143 from mod_python import apache
144 try:
145 global _isSetUp
146 if not _isSetUp:
147 setup(req)
148 _isSetUp = True
149
150 # Obtain a Request object from CherryPy
151 local = req.connection.local_addr
152 local = httputil.Host(
153 local[0], local[1], req.connection.local_host or '')
154 remote = req.connection.remote_addr
155 remote = httputil.Host(
156 remote[0], remote[1], req.connection.remote_host or '')
157
158 scheme = req.parsed_uri[0] or 'http'
159 req.get_basic_auth_pw()
160
161 try:
162 # apache.mpm_query only became available in mod_python 3.1
163 q = apache.mpm_query
164 threaded = q(apache.AP_MPMQ_IS_THREADED)
165 forked = q(apache.AP_MPMQ_IS_FORKED)
166 except AttributeError:
167 bad_value = ("You must provide a PythonOption '%s', "
168 "either 'on' or 'off', when running a version "
169 'of mod_python < 3.1')
170
171 options = req.get_options()
172
173 threaded = options.get('multithread', '').lower()
174 if threaded == 'on':
175 threaded = True
176 elif threaded == 'off':
177 threaded = False
178 else:
179 raise ValueError(bad_value % 'multithread')
180
181 forked = options.get('multiprocess', '').lower()
182 if forked == 'on':
183 forked = True
184 elif forked == 'off':
185 forked = False
186 else:
187 raise ValueError(bad_value % 'multiprocess')
188
189 sn = cherrypy.tree.script_name(req.uri or '/')
190 if sn is None:
191 send_response(req, '404 Not Found', [], '')
192 else:
193 app = cherrypy.tree.apps[sn]
194 method = req.method
195 path = req.uri
196 qs = req.args or ''
197 reqproto = req.protocol
198 headers = list(req.headers_in.copy().items())
199 rfile = _ReadOnlyRequest(req)

Callers 3

decoratedFunction · 0.85
__call__Method · 0.85
wrapperFunction · 0.85

Calls 12

format_excFunction · 0.90
bare_errorFunction · 0.90
send_responseFunction · 0.85
_ReadOnlyRequestClass · 0.85
itemsMethod · 0.80
get_servingMethod · 0.80
release_servingMethod · 0.80
logMethod · 0.80
setupFunction · 0.70
getMethod · 0.45
script_nameMethod · 0.45
runMethod · 0.45

Tested by 1

wrapperFunction · 0.68

Used in the wild real call sites across dependent graphs

searching dependent graphs…