Google Groups Home
Help | Sign in
FieldsMatch validation
There are currently too many topics in this group that display first. To make this topic appear first, remove this option from another topic.
There was an error processing your request. Please try again.
flag
  3 messages - Collapse all
The group you are posting to is a Usenet group. Messages posted to this group will make your email address visible to anyone on the Internet.
Your reply message has not been sent.
Your post was successful
Jens.Hoffrichter@gmail.co m  
View profile
 More options Jul 17, 5:21 pm
From: "Jens.Hoffrich...@gmail.com" <Jens.Hoffrich...@gmail.com>
Date: Thu, 17 Jul 2008 14:21:10 -0700 (PDT)
Local: Thurs, Jul 17 2008 5:21 pm
Subject: FieldsMatch validation
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


    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Alberto Valverde  
View profile
 More options Jul 18, 6:08 am
From: "Alberto Valverde" <albe...@toscat.net>
Date: Fri, 18 Jul 2008 12:08:12 +0200 (CEST)
Local: Fri, Jul 18 2008 6:08 am
Subject: Re: [TW] FieldsMatch validation

That code should work... err, no, you've got a typo there, try:

validator = v.Schema(...)
(without the trailing s)

Alberto


    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Jens Hoffrichter  
View profile
 More options Jul 18, 8:54 am
From: "Jens Hoffrichter" <jens.hoffrich...@gmail.com>
Date: Fri, 18 Jul 2008 14:54:42 +0200
Local: Fri, Jul 18 2008 8:54 am
Subject: Re: [TW] Re: FieldsMatch validation
Hi,

2008/7/18 Alberto Valverde <albe...@toscat.net>:

> That code should work... err, no, you've got a typo there, try:

> validator = v.Schema(...)
> (without the trailing s)

I was SURE I had tried that, as I have tried a lot of stuff last
night. But you are right, it works like that :) You just need to put
the chained_validators in a list, like chained_validators = [
v.FieldsMatchValidator(...) ], otherwise tw can't iterate over it.

Thanks for the help :)

Jens


    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
End of messages
« Back to Discussions « Newer topic     Older topic »

Create a group - Google Groups - Google Home - Terms of Service - Privacy Policy
©2008 Google