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

Function select_app_without_default

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

Source from the content-addressed store, hash-verified

435
436
437def select_app_without_default(environ, start_response):
438 req = Request(environ)
439 status = b"200 OK"
440 if req.method == "GET":
441 body = to_bytes("""
442<html>
443 <head><title>form page</title></head>
444 <body>
445 <form method="POST" id="single_select_form">
446 <select id="single" name="single">
447 <option value="4">Four</option>
448 <option value="5">Five</option>
449 <option value="6">Six</option>
450 <option value="7">Seven</option>
451 </select>
452 <input name="button" type="submit" value="single">
453 </form>
454 <form method="POST" id="multiple_select_form">
455 <select id="multiple" name="multiple" multiple="multiple">
456 <option value="8">Eight</option>
457 <option value="9">Nine</option>
458 <option value="10">Ten</option>
459 <option value="11">Eleven</option>
460 </select>
461 <input name="button" type="submit" value="multiple">
462 </form>
463 </body>
464</html>
465""")
466 else:
467 select_type = req.POST.get("button")
468 if select_type == "single":
469 selection = req.POST.get("single")
470 elif select_type == "multiple":
471 selection = ", ".join(req.POST.getall("multiple"))
472 body = to_bytes("""
473<html>
474 <head><title>display page</title></head>
475 <body>
476 <p>You submitted the %(select_type)s </p>
477 <p>You selected %(selection)s</p>
478 </body>
479</html>
480""" % dict(selection=selection, select_type=select_type))
481
482 headers = [
483 ('Content-Type', 'text/html; charset=utf-8'),
484 ('Content-Length', str(len(body)))]
485 # PEP 3333 requires native strings:
486 headers = [(str(k), str(v)) for k, v in headers]
487 start_response(status, headers)
488 return [body]
489
490
491def select_app_unicode(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…