Return-Path: Delivered-To: apmail-couchdb-user-archive@www.apache.org Received: (qmail 60343 invoked from network); 10 Feb 2009 21:10:14 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.2) by minotaur.apache.org with SMTP; 10 Feb 2009 21:10:14 -0000 Received: (qmail 20314 invoked by uid 500); 10 Feb 2009 21:10:08 -0000 Delivered-To: apmail-couchdb-user-archive@couchdb.apache.org Received: (qmail 20269 invoked by uid 500); 10 Feb 2009 21:10:08 -0000 Mailing-List: contact user-help@couchdb.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: user@couchdb.apache.org Delivered-To: mailing list user@couchdb.apache.org Received: (qmail 20258 invoked by uid 99); 10 Feb 2009 21:10:08 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 10 Feb 2009 13:10:08 -0800 X-ASF-Spam-Status: No, hits=-0.0 required=10.0 tests=SPF_PASS X-Spam-Check-By: apache.org Received-SPF: pass (nike.apache.org: domain of b.candler@pobox.com designates 208.72.237.25 as permitted sender) Received: from [208.72.237.25] (HELO sasl.smtp.pobox.com) (208.72.237.25) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 10 Feb 2009 21:09:59 +0000 Received: from localhost.localdomain (unknown [127.0.0.1]) by b-sasl-quonix.sasl.smtp.pobox.com (Postfix) with ESMTP id E6E712AD6D; Tue, 10 Feb 2009 16:09:31 -0500 (EST) Received: from mappit (unknown [80.45.95.114]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by b-sasl-quonix.sasl.smtp.pobox.com (Postfix) with ESMTPSA id 48FC72ACE9; Tue, 10 Feb 2009 16:09:30 -0500 (EST) Received: from brian by mappit with local (Exim 4.69) (envelope-from ) id 1LWzrE-0005ES-JV; Tue, 10 Feb 2009 21:09:28 +0000 Date: Tue, 10 Feb 2009 21:09:28 +0000 From: Brian Candler To: Chris Anderson Cc: user@couchdb.apache.org Subject: Re: Database Disruption From The Couch Message-ID: <20090210210928.GA19534@uk.tiscali.com> References: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.5.17+20080114 (2008-01-14) X-Pobox-Relay-ID: 1C6B229A-F7B7-11DD-9055-6F7C8D1D4FD0-28021239!a-sasl-quonix.pobox.com X-Virus-Checked: Checked by ClamAV on apache.org On Mon, Feb 09, 2009 at 11:30:30AM -0800, Chris Anderson wrote: > > (1) Personally, I'm not yet ready to move all view generation into the > > browser (Futon-like), i.e. where Javascript fetches the JSON, reformats as > > HTML, and submits back as JSON. In any case, supporting browsers without > > Javascript is still a useful capability. > > The _show and _list features give you the capability to serve HTML or > other content types directly based on either doc or view queries. They > are a little lacking in documentation, but the test suite should be > enough to get your started. Thanks. If I understand correctly, _show only acts on a single document? In practice this may be less of a problem with couchdb than with a SQL-backed system (where a single page often combines multiple models), but I can still see cases where I want to combine a document with some related summary information from a view. Maybe this could be done with iframes. Similarly, AFAICT _list is also basic: a header, N rows from a single view, a footer. > If it doesn't work already, it'd be trivial to teach Couch to > understand norm HTML form POSTs, with some bare-bones conversion to a > JSON document (eg: each field is treated as a string, in a flat > namespace) Again, I expect here that a single POST will only be able to update a single document. But the Rails-type way of doing nested parameters maps well to JSON: foo[bar]=hello => {"foo":{"bar":"hello"}} foo[bar][]=hello&foo[bar][]=world => {"foo":{"bar":["hello","world"]}} > > (4) Error handling: for Javascript user interfaces, if they are going to > > rely on the JSON response for failed 'model' validation, then the JSON error > > format needs to be carefully described and sufficiently detailled that the > > front-end can display meaningful messages to the user, e.g. which particular > > fields are invalid and why. > > Agreed - I'm working on some validation helpers for Couchapp and my > Sofa blog. Part of what's up in the air here is where to draw the line > between the "standard library" of helpers included with CouchDB, and > what should be maintained in its own project. Yes. I looked at Sofa's validation, and it basically just throws an error on the first erroneous field it finds: if (type == 'post') { // post required fields require(author, "Posts must have an author.") require(newDoc.body, "Posts must have a body field") require(newDoc.html, "Posts must have an html field."); ... etc => {"forbidden":"Posts must have an author."} etc If there could be library support for building an errors structure which maps individual tags in the source object to errors for that field, that would be useful - not least because a well-defined structure could then be interpreted by a corresponding library at the client side. Cheers, Brian.