On Sun, 2011-03-20 at 14:34 -0700, oO wrote:
> How should the interaction between the deform Form object and the DB
> backend be modeled? I have a schema that represents a user with at its
> most simple contains a email and password field.
>
> class User(colander.MappingSchema):
> """"""
> email = colander.SchemaNode(
> colander.String(),
> validator = colander.Email()
> )
> password = colander.SchemaNode(
> colander.String(),
> missing=colander.null,
> widget=widget.CheckedPasswordWidget()
> )
>
>
> form = Form( UserSchema() )
> try:
> data = form.validate( controls )
> create_record( data )
> except ValidationFailure, e:
> return {'form' : e.render()}
>
> Of course the second stage of the validation is to try to insert this
> user into my database (I'm using MongoDB, but the problem is the same
> for any backend store). The insert will fail if the email address is
> not unique, but I won't know until I actually try to insert the record
> in the database.
I should also point out
http://docs.pylonsproject.org/projects/colander/dev/binding.html (used
by most of the examples on deformdemo.repoze.org).
- C
--
You received this message because you are subscribed to the Google Groups
"pylons-discuss" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/pylons-discuss?hl=en.