gae-init/gae-init — pull request #4 by gmist (2013-10-04 12:41:34+00:00)
Title: Config form populate

Using the code like:
```
if form.validate_on_submit():
...
config_db.feedback_email = form.feedback_email.data.strip()
...
```
is not always the best approach because validation of the field called before the call function strip(). For example, the user enters email: "a@a.com ". From the point of view of the validator - it is an invalid email address:
![screenshot 2013-10-04 15 40 36](https://f.cloud.github.com/assets/47926/1268913/ae8dce38-2cec-11e3-99f7-1c038cb5fd97.png)

But from the point of view of the user - this is right email address. The more better way is to use WTForm filters that are called before field validation:
```
my_cool_filter = lambda x: x.strip() if x else ''

class MyForm(wtf.Form):
email = wtf.TextField('Email',
[wtf.validators.optional(), wtf.validators.email()],
filters=[my_cool_filter])
```

If you use filters, you can greatly simplify the code assignment fields. Instead of:
```
if form.validate_on_submit():
config_db.feedback_email = form.feedback_email.data.strip()
.... dozens of lines ....
config_db.github_client_secret = form.github_client_secret.data.strip()
config_db.put()
```
Just write:
```
if form.validate_on_submit():
form.populate_obj(config_db)
config_db.put()
```