MCPcopy Create free account
hub / github.com/Pylons/webtest / select_app

Function select_app

tests/test_forms.py:329–380  ·  view source on GitHub ↗
(environ, start_response)

Source from the content-addressed store, hash-verified

327
328
329def select_app(environ, start_response):
330 req = Request(environ)
331 status = b"200 OK"
332 if req.method == "GET":
333 body = to_bytes("""
334<html>
335 <head><title>form page</title></head>
336 <body>
337 <form method="POST" id="single_select_form">
338 <select id="single" name="single">
339 <option value="4">Four</option>
340 <option value="5" selected="selected">Five</option>
341 <option value="6">Six</option>
342 <option value="7">Seven</option>
343 </select>
344 <input name="button" type="submit" value="single">
345 </form>
346 <form method="POST" id="multiple_select_form">
347 <select id="multiple" name="multiple" multiple>
348 <option value="8" selected="selected">Eight</option>
349 <option value="9">Nine</option>
350 <option value="10">Ten</option>
351 <option value="11" selected="selected">Eleven</option>
352 </select>
353 <input name="button" type="submit" value="multiple">
354 </form>
355 </body>
356</html>
357""")
358 else:
359 select_type = req.POST.get("button")
360 if select_type == "single":
361 selection = req.POST.get("single")
362 elif select_type == "multiple":
363 selection = ", ".join(req.POST.getall("multiple"))
364 body = to_bytes("""
365<html>
366 <head><title>display page</title></head>
367 <body>
368 <p>You submitted the %(select_type)s </p>
369 <p>You selected %(selection)s</p>
370 </body>
371</html>
372""" % dict(selection=selection, select_type=select_type))
373
374 headers = [
375 ('Content-Type', 'text/html; charset=utf-8'),
376 ('Content-Length', str(len(body)))]
377 # PEP 3333 requires native strings:
378 headers = [(str(k), str(v)) for k, v in headers]
379 start_response(status, headers)
380 return [body]
381
382
383def select_app_without_values(environ, start_response):

Callers

nothing calls this directly

Calls 2

to_bytesFunction · 0.90
getMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…