I'm also interested in learning how to handle integrity exceptions so
that the user can see those errors on the form. Probably something to
do with parsing the IntegrityError (sqla) being thrown and figuring
out the field there and doing something with that? Would like to know
your thoughts.

On Mar 20, 3:41 pm, Chris McDonough <[email protected]> wrote:
> 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 
> outhttp://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.

Reply via email to