Jens.Hof...@gmail.com
unread,Jul 17, 2008, 5:21:10 PM7/17/08Sign in to reply to author
Sign in to forward
You do not have permission to delete messages in this group
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to ToscaWidgets-discuss
Hello all,
First thanks to Alberto for pointing me to group, so I will be just
bothering you instead of the pylons world ;)
A few words about myself: I'm an experienced python and web
programmer, with more than 5 years experience in Python, and
web......well, I don't really want to count those :) I have created
web applications in a lot of different, common (and not-so-common)
languages, but there are still things to learn.
My biggest web project with Python was a bigger site building on top
of pure Myghty, but when I got now a request for a new project, I
decided to give pylons a try, and after asking which way to build
forms best, I got pointed to ToscaWidgets and tw.forms, so, here I am.
I have created my first form successfully already, and it is working
so far, the only thing I can't get to run even after an hour of
reading docs and googling, is the FieldsMatch validator (for a user
registration form, of course)
Here is the code for the widget:
--- snip ---
from tw import forms
from tw.api import WidgetsList
import tw.forms.validators as v
forms.FormField.engine_name = "mako"
class RegisterForm(forms.ListForm):
class fields(WidgetsList):
username = forms.TextField(validator = v.All( v.MinLength(5),
v.MaxLength(32), v.UnicodeString(not_empty = True), v.PlainText()))
givenname = forms.TextField()
surname = forms.TextField()
email = forms.TextField(validator = v.Email(not_empty = True))
password = forms.PasswordField( validator = v.MinLength(7,
not_empty = True))
password_repeat = forms.PasswordField()
gender = forms.SingleSelectField(
options = [ "male", "female" ]
)
validators = v.Schema(chained_validators =
v.FieldsMatch('password','password_repeat'))
register = RegisterForm('post_register')
--- snip ---
I spare you the templates and controllers, as those stuff seems to
work, the validators return errors and so on. So, how do I have to
implement such a Schema on top of tw that it will moan if the two
passwords don't match?
Thanks in advance,
Jens