Account Options

  1. Sign in
The old Google Groups will be going away soon, but your browser is incompatible with the new version.
Google Groups Home
« Groups Home
Deform for CouchDB-like databases
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
  7 messages - Collapse all  -  Translate all to Translated (View all originals)
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
 
From:
To:
Cc:
Followup To:
Add Cc | Add Followup-to | Edit Subject
Subject:
Validation:
For verification purposes please type the characters you see in the picture below or the numbers you hear by clicking the accessibility icon. Listen and type the numbers you hear
 
Mark Huang  
View profile  
 More options Oct 7 2012, 4:56 am
From: Mark Huang <zhengha...@gmail.com>
Date: Sun, 7 Oct 2012 01:56:18 -0700 (PDT)
Local: Sun, Oct 7 2012 4:56 am
Subject: Deform for CouchDB-like databases

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.  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 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.
Chris McDonough  
View profile  
 More options Oct 7 2012, 5:33 am
From: Chris McDonough <chr...@plope.com>
Date: Sun, 07 Oct 2012 05:33:11 -0400
Local: Sun, Oct 7 2012 5:33 am
Subject: Re: Deform for CouchDB-like databases

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


 
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.
Mathieu Le Marec - Pasquet  
View profile  
 More options Oct 7 2012, 5:34 am
From: Mathieu Le Marec - Pasquet <mathieu.pasq...@gmail.com>
Date: Sun, 07 Oct 2012 11:33:45 +0200
Local: Sun, Oct 7 2012 5:33 am
Subject: Re: Deform for CouchDB-like databases

On 07/10/2012 10:56, Mark Huang wrote:

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.


 
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.
Mark Huang  
View profile  
 More options Oct 7 2012, 9:15 am
From: Mark Huang <zhengha...@gmail.com>
Date: Sun, 7 Oct 2012 06:15:42 -0700 (PDT)
Local: Sun, Oct 7 2012 9:15 am
Subject: Re: Deform for CouchDB-like databases

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.


 
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.
Mark Huang  
View profile  
 More options Oct 7 2012, 9:24 am
From: Mark Huang <zhengha...@gmail.com>
Date: Sun, 7 Oct 2012 06:24:46 -0700 (PDT)
Local: Sun, Oct 7 2012 9:24 am
Subject: Re: Deform for CouchDB-like databases

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.  

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.  

Advise needed.  Thanks in advance!


 
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.
Randall Leeds  
View profile  
 More options Oct 8 2012, 3:55 pm
From: Randall Leeds <randall.le...@gmail.com>
Date: Mon, 8 Oct 2012 12:55:00 -0700
Subject: Re: Deform for CouchDB-like databases

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.

Read the sections called "Deform Components" and "Serialization and
Deserialization" in the deform documentation and things should become
more clear.
http://docs.pylonsproject.org/projects/deform/en/latest/index.html

-Randall


 
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.
Randall Leeds  
View profile  
 More options Oct 8 2012, 4:02 pm
From: Randall Leeds <randall.le...@gmail.com>
Date: Mon, 8 Oct 2012 13:02:12 -0700
Local: Mon, Oct 8 2012 4:02 pm
Subject: Re: Deform for CouchDB-like databases

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.

-Randall


 
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 »