Why?
form2 is different from form. And Quixote demo only contains form. form2 itself contains the remark "... a good docstring is needed". The only reference and explanation is hidden quite well within the quixote-user-mailinglist. 2 times I had to search
and now
I cutted and pasted the sample code from Neil Schemenauer into this Wiki
1 from <...> import get_user
2 from <...> import header, footer
3 from quixote import htmltext
4 from quixote.form2 import Form, StringWidget, PasswordWidget
5
6 def login_form(request):
7 form = Form(use_tokens=False)
8 form.add(StringWidget, 'user_id', title='User ID')
9 form.add(PasswordWidget, 'password', title='Password')
10 form.add_submit('login', 'Login')
11
12 def render [html] ():
13 header()
14 form.render()
15 footer()
16
17 if not form.is_submitted():
18 return render()
19
20 user_id = form['user_id']
21 password = form['password']
22 if not user_id:
23 form.set_error('user_id', "You must supply a user ID")
24 user = get_user(user_id)
25 if user_id and not user:
26 form.set_error('user_id', "Invalid user ID")
27 if user and not password:
28 send_new_password(user)
29 form.set_error('password',
30 "A new password has been generated and "
31 "e-mailed to your address.")
32 if user and password and not user.valid_password(password):
33 form.set_error('password', "Incorrect password")
34
35 if form.has_errors():
36 return render()
37
38 request.session.set_user(user)
39 return htmltext(request.redirect("/"))
40
41 def send_new_password(user):
42 ...
43