/usr/share/pyshared/quixote/demo/widgets.ptl is in python-quixote1 1.2-5.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 | # quixote.demo.widgets
#
# Demonstrate the Quixote widget classes.
__revision__ = "$Id: widgets.ptl 23532 2004-02-20 22:38:57Z dbinger $"
import time
from quixote.form import widget
def widgets(request):
# Whether we are generating or processing the form with these
# widgets, we need all the widget objects -- so create them now.
widgets = {}
widgets['name'] = widget.StringWidget('name', size=20)
widgets['password'] = widget.PasswordWidget(
'password', size=20, maxlength=20)
widgets['confirm'] = widget.CheckboxWidget('confirm')
widgets['colour'] = widget.RadiobuttonsWidget(
'colour', allowed_values=['green', 'blue', 'brown', 'other'])
widgets['size'] = widget.SingleSelectWidget(
'size', value='medium',
allowed_values=['tiny', 'small', 'medium', 'large', 'enormous'],
descriptions=['Tiny (4")', 'Small (6")', 'Medium (10")',
'Large (14")', 'Enormous (18")'])
widgets['toppings'] = widget.MultipleSelectWidget(
'toppings', value=['cheese'],
allowed_values=['cheese', 'pepperoni', 'green peppers', 'mushrooms',
'sausage', 'anchovies', 'onions'],
size=5)
widgets['time'] = widget.HiddenWidget('time', value=time.time())
if request.form:
# If we have some form data, then we're being invoked to process
# the form; call process_widgets() to do the real work. We only
# handle it in this page to conserve urls: the "widget" url both
# generates the form and processes it, and behaves very
# differently depending on whether there are form variables
# present when it is invoked.
return process_widgets(request, widgets)
else:
# No form data, so generate the form from scratch. When the
# user submits it, we'll come back to this page, but
# request.form won't be empty that time -- so we'll call
# process_widgets() instead.
return render_widgets(request, widgets)
def render_widgets [html] (request, widgets):
"""\
<html>
<head><title>Quixote Widget Demo</title></head>
<body>
<h1>Quixote Widget Demo</h1>
"""
"""\
<form method="POST" action="widgets">
<table>
"""
row_fmt = '''\
<tr>
<th align="left">%s</th>
<td colspan=2>%s</td>
</tr>
'''
row_fmt % ("Your name", widgets['name'].render(request))
row_fmt % ("Password", widgets['password'].render(request))
row_fmt % ("Are you sure?", widgets['confirm'].render(request))
row_fmt % ("Eye colour", widgets['colour'].render(request))
'''\
<tr>
<th align="left" valign="top">Select a<br>size of pizza</th>
<td valign="top">%s</td>
<th align="left" valign="top">And some<br>pizza toppings</th>
<td valign="top">%s</td>
</tr>
''' % (widgets['size'].render(request),
widgets['toppings'].render(request))
widgets['time'].render(request)
'</table>\n'
widget.SubmitButtonWidget(value="Submit").render(request)
'''\
</form>
</body>
</html>
'''
def process_widgets [html] (request, widgets):
"""\
<html>
<head><title>Quixote Widget Demo</title></head>
<body>
<h2>You entered the following values:</h2>
<table>
"""
row_fmt = ' <tr><th align="left">%s</th><td>%s</td></tr>\n'
fallback = '<i>nothing</i>'
row_fmt % ("name",
widgets['name'].parse(request) or fallback)
row_fmt % ("password",
widgets['password'].parse(request) or fallback)
row_fmt % ("confirmation",
widgets['confirm'].parse(request))
row_fmt % ("eye colour",
widgets['colour'].parse(request) or fallback)
row_fmt % ("pizza size",
widgets['size'].parse(request) or fallback)
toppings = widgets['toppings'].parse(request)
row_fmt % ("pizza toppings",
toppings and (", ".join(toppings)) or fallback)
'</table>\n'
form_time = float(widgets['time'].parse(request))
now = time.time()
("<p>It took you %.1f sec to fill out and submit the form</p>\n"
% (now - form_time))
"""\
</body>
</html>
"""
|