I have a question about form handling with packages like Deform/Colander. From my brief understanding, these packages assume that you use a relational database so that it can create a schema for your form. The problem with my use-case is that I am using CouchDB, a document database.
Would deform work for CouchDB? Are there any packages that do something similar like deform for Pyramid using CouchDB?
On Sun, 2012-10-07 at 01:56 -0700, Mark Huang wrote:
> Hi,
> I have a question about form handling with packages like
> Deform/Colander. From my brief understanding, these packages assume
> that you use a relational database so that it can create a schema for
> your form.
No, this is not correct. Neither deform nor colander assume anything
about databases; they know nothing about databases.
> The problem with my use-case is that I am using CouchDB, a document
> database.
> Would deform work for CouchDB? Are there any packages that do
> something similar like deform for Pyramid using CouchDB?
> -- > You received this message because you are subscribed to the Google
> Groups "pylons-discuss" group.
> To view this discussion on the web visit
> https://groups.google.com/d/msg/pylons-discuss/-/GfP1phJlm1YJ.
> To post to this group, send email to pylons-discuss@googlegroups.com.
> To unsubscribe from this group, send email to pylons-discuss
> +unsubscribe@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/pylons-discuss?hl=en.
> I have a question about form handling with packages like Deform/Colander. > From my brief understanding, these packages assume that you use a relational > database so that it can create a schema for your form. The problem with my > use-case is that I am using CouchDB, a document database.
> Would deform work for CouchDB? Are there any packages that do something > similar like deform for Pyramid using CouchDB?
> Regards,
> Mark Huang
> -- > You received this message because you are subscribed to the Google Groups > "pylons-discuss" group.
> To view this discussion on the web visit > https://groups.google.com/d/msg/pylons-discuss/-/GfP1phJlm1YJ.
> To post to this group, send email to pylons-discuss@googlegroups.com.
> To unsubscribe from this group, send email to > pylons-discuss+unsubscribe@googlegroups.com.
> For more options, visit this group at > http://groups.google.com/group/pylons-discuss?hl=en.
Deform use colander for determining schemas.
Colander is database agnostic.
You just have tools to guess the schema from your database.
-- Cordialement,
Mathieu Le Marec - Pasquet
Pensez à l'environnement.
N'imprimez ce courriel que si vous en avez vraiment besoin.
Oh? Thanks for the enlightenment. It's just that the examples always mention the words "relational database", so I always had the misconception of it being dependent on a RDBMS.
On Sunday, 7 October 2012 17:33:19 UTC+8, Chris McDonough wrote:
> On Sun, 2012-10-07 at 01:56 -0700, Mark Huang wrote: > > Hi,
> > I have a question about form handling with packages like > > Deform/Colander. From my brief understanding, these packages assume > > that you use a relational database so that it can create a schema for > > your form.
> No, this is not correct. Neither deform nor colander assume anything > about databases; they know nothing about databases.
> > The problem with my use-case is that I am using CouchDB, a document > > database.
> > Would deform work for CouchDB? Are there any packages that do > > something similar like deform for Pyramid using CouchDB?
> Deform. ;-)
> - C
> > Regards, > > Mark Huang
> > -- > > You received this message because you are subscribed to the Google > > Groups "pylons-discuss" group. > > To view this discussion on the web visit > > https://groups.google.com/d/msg/pylons-discuss/-/GfP1phJlm1YJ. > > To post to this group, send email to pylons-...@googlegroups.com<javascript:>.
> > To unsubscribe from this group, send email to pylons-discuss > > +unsub...@googlegroups.com <javascript:>. > > For more options, visit this group at > > http://groups.google.com/group/pylons-discuss?hl=en.
Do all the form packages like formalchemy or Deform assume that forms are submitted via a "form submit" action?
I am contemplating on using Deform for my form validations, but I am currently submitting the forms using an AJAX POST request; sending data as JSON to the backend Pyramid. Why? Well, the forms are a bit complex and because I use CouchDB, the JSON is easily saved. The problem is, I need to write a bunch of code to validate the received JSON from the frontend.
Is this a right or wrong way? Part of me feels that this way is more convenient to save the data, but I would be unable to make use of the beaker session object, say for showing flash messages.
On Sunday, 7 October 2012 17:33:19 UTC+8, Chris McDonough wrote:
> On Sun, 2012-10-07 at 01:56 -0700, Mark Huang wrote: > > Hi,
> > I have a question about form handling with packages like > > Deform/Colander. From my brief understanding, these packages assume > > that you use a relational database so that it can create a schema for > > your form.
> No, this is not correct. Neither deform nor colander assume anything > about databases; they know nothing about databases.
> > The problem with my use-case is that I am using CouchDB, a document > > database.
> > Would deform work for CouchDB? Are there any packages that do > > something similar like deform for Pyramid using CouchDB?
> Deform. ;-)
> - C
> > Regards, > > Mark Huang
> > -- > > You received this message because you are subscribed to the Google > > Groups "pylons-discuss" group. > > To view this discussion on the web visit > > https://groups.google.com/d/msg/pylons-discuss/-/GfP1phJlm1YJ. > > To post to this group, send email to pylons-...@googlegroups.com<javascript:>.
> > To unsubscribe from this group, send email to pylons-discuss > > +unsub...@googlegroups.com <javascript:>. > > For more options, visit this group at > > http://groups.google.com/group/pylons-discuss?hl=en.
On Sun, Oct 7, 2012 at 6:24 AM, Mark Huang <zhengha...@gmail.com> wrote:
> Ok I have another question....
> Do all the form packages like formalchemy or Deform assume that forms are
> submitted via a "form submit" action?
> I am contemplating on using Deform for my form validations, but I am
> currently submitting the forms using an AJAX POST request; sending data as
> JSON to the backend Pyramid. Why? Well, the forms are a bit complex and
> because I use CouchDB, the JSON is easily saved. The problem is, I need to
> write a bunch of code to validate the received JSON from the frontend.
Deform does not care.
Here's the connected pieces:
deform.Form
- is made up of deform.Field objects
- each of which is associated with a
- colander.SchemaNode
- deform.Widget
The form POST data is actually pre-processed by peppercorn, but you
probably don't need to think much about that. The key steps for
validation are the deserialization fo the POST data according to the
Widget hierarchy and then the validation of the resulting cstruct
against the schema hierarchy.
The comments and code for the `deform.Field.validate` method make much
of this clear.
If you're passing in JSON that matches your colander Schema, then you
already have the `cstruct` and just need to call `schema.deserialize`
on it.
The widgets are there to handle the templating for the fields and to
cover other UI details which are orthogonal to the schema model (for
example, a CheckedPasswordWidget serializes to two fields, with a
validator to ensure they match, but deserializes to a single field in
the resulting object... your user only has one password, it's merely a
detail of the form that there are two fields).
This separation of concerns between the widget and the schema is the
reason I like deform so much.
On Mon, Oct 8, 2012 at 12:55 PM, Randall Leeds <randall.le...@gmail.com> wrote:
> On Sun, Oct 7, 2012 at 6:24 AM, Mark Huang <zhengha...@gmail.com> wrote:
>> Ok I have another question....
>> Do all the form packages like formalchemy or Deform assume that forms are
>> submitted via a "form submit" action?
>> I am contemplating on using Deform for my form validations, but I am
>> currently submitting the forms using an AJAX POST request; sending data as
>> JSON to the backend Pyramid. Why? Well, the forms are a bit complex and
>> because I use CouchDB, the JSON is easily saved. The problem is, I need to
>> write a bunch of code to validate the received JSON from the frontend.
> Deform does not care.
> Here's the connected pieces:
> deform.Form
> - is made up of deform.Field objects
> - each of which is associated with a
> - colander.SchemaNode
> - deform.Widget
> The form POST data is actually pre-processed by peppercorn, but you
> probably don't need to think much about that. The key steps for
> validation are the deserialization fo the POST data according to the
> Widget hierarchy and then the validation of the resulting cstruct
> against the schema hierarchy.
> The comments and code for the `deform.Field.validate` method make much
> of this clear.
> If you're passing in JSON that matches your colander Schema, then you
> already have the `cstruct` and just need to call `schema.deserialize`
> on it.
On the other hand, if you're passing the form data in raw, as strings
and with two entries for checked fields, etc, then you may want to
call `form.widget.deserialize` to get your cstruct.
POST data --(peppercorn)--> pstruct --(deform)--> cstruct --
(colander) --> appstruct
If you're not dealing with any pre-schema transformations, such as
those provided by the widgets, then you can actually skip deform
altogether and just use colander.
Again, `deform.Field.validate()` is a short read and shows the high
level operation of all of this.