From user-return-9078-apmail-couchdb-user-archive=couchdb.apache.org@couchdb.apache.org Tue Mar 02 18:41:16 2010 Return-Path: Delivered-To: apmail-couchdb-user-archive@www.apache.org Received: (qmail 24159 invoked from network); 2 Mar 2010 18:41:15 -0000 Received: from unknown (HELO mail.apache.org) (140.211.11.3) by 140.211.11.9 with SMTP; 2 Mar 2010 18:41:15 -0000 Received: (qmail 3224 invoked by uid 500); 2 Mar 2010 18:41:10 -0000 Delivered-To: apmail-couchdb-user-archive@couchdb.apache.org Received: (qmail 3075 invoked by uid 500); 2 Mar 2010 18:41:10 -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 3058 invoked by uid 99); 2 Mar 2010 18:41:10 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 02 Mar 2010 18:41:10 +0000 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 jchris@gmail.com designates 209.85.220.209 as permitted sender) Received: from [209.85.220.209] (HELO mail-fx0-f209.google.com) (209.85.220.209) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 02 Mar 2010 18:40:59 +0000 Received: by fxm1 with SMTP id 1so627159fxm.35 for ; Tue, 02 Mar 2010 10:40:38 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:received:received:content-type:mime-version :subject:from:in-reply-to:date:content-transfer-encoding:message-id :references:to:x-mailer; bh=Bowby5MDUwuUZ7qc71Cuj3HsP+1Z8ee2jt7LBGZfV4A=; b=ucCFDllsnZsXUrIAKfi3e2c7UZRBEp0xHVcq/NkyRO76UG3lkEvCTy9UhoDztkys6g h+liG9OWsPD4xZkWUyEuYYp51ebpeCnTOEV9wZxgUUaZhZ1U4un86PxxHS3nbNeuq7df ovzJTEqmVWWyWt3FjWwMe/zuLHHNqFUOhXoKE= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=content-type:mime-version:subject:from:in-reply-to:date :content-transfer-encoding:message-id:references:to:x-mailer; b=U6Q6m4Z2MGh1p8YpeWZK/Q4gaYNs4d1VIEWt80NWftBhzsh8YtENKgMb4FSO6RYNbL GdF3G5AYgnQkkvbIyNYVXaPNLX2TgHvZqqPUsLemGbYEwrwK1G1YWA8I+mvAWJljM0aq y3LQpoP01NIHaF3lh/ZVmyJPGrx2N5rpyY9Fg= Received: by 10.223.13.129 with SMTP id c1mr6977260faa.103.1267555238221; Tue, 02 Mar 2010 10:40:38 -0800 (PST) Received: from ?192.168.1.104? (c-98-248-172-14.hsd1.ca.comcast.net [98.248.172.14]) by mx.google.com with ESMTPS id 15sm3070059fxm.0.2010.03.02.10.40.34 (version=TLSv1/SSLv3 cipher=RC4-MD5); Tue, 02 Mar 2010 10:40:36 -0800 (PST) Content-Type: text/plain; charset=us-ascii Mime-Version: 1.0 (Apple Message framework v1077) Subject: Re: Default values via _updates function From: J Chris Anderson In-Reply-To: <33bc4c3c1003021037y554be14cg9fd8b98f6b562da6@mail.gmail.com> Date: Tue, 2 Mar 2010 10:40:30 -0800 Content-Transfer-Encoding: quoted-printable Message-Id: <17524F96-716A-4203-95BC-4D40AD0BBB4D@gmail.com> References: <33bc4c3c1003011453p6815da72t5b3c5f419999522f@mail.gmail.com> <6547666A-820B-4D6C-B9E0-C698B061EDDE@sourcegarden.de> <33bc4c3c1003020644h29348f8fgcb10c868ef962615@mail.gmail.com> <33bc4c3c1003021037y554be14cg9fd8b98f6b562da6@mail.gmail.com> To: user@couchdb.apache.org X-Mailer: Apple Mail (2.1077) X-Virus-Checked: Checked by ClamAV on apache.org On Mar 2, 2010, at 10:37 AM, Jim Garvin wrote: > I tried building from the *trunk* branch on the git mirror, = specifically: >=20 > commit e13a88b46cfad2603c636cf5781469f25e9d365f > Author: Jan Lehnardt > Date: Mon Mar 1 19:46:19 2010 +0000 >=20 > Add RC note >=20 > And I got stuck with a completely new issue: Trying to create/save a > document results in the "attempted upload of invalid JSON" error every = time. >=20 hmm. Might be worth investigating your toolchain. Trunk is very stable = right now (1.0 release candidate) so if it's not working for you, that's = a sign of something wrong on your end. (I hope!) Are the Futon tests passing on trunk for you? Chris > [error] [<0.5552.0>] attempted upload of invalid JSON > = {"_id":"c21df46f6ad441613897517c085114a6","_rev":"1-c9a66d15ed47ea129687e6= 45ae3ce9d2","service":"test","body":"foo","created_at":"2010-03-01 > 09:52:32 -0500"} >=20 > So I'm about to roll back to 0.10.1 and try just applying that simple = patch > you suggested. >=20 > Fingers crossed. >=20 > Thanks, > Jim >=20 > On Tue, Mar 2, 2010 at 12:05 PM, J Chris Anderson = wrote: >=20 >>=20 >> On Mar 2, 2010, at 6:44 AM, Jim Garvin wrote: >>=20 >>> *Chris,* >>>=20 >>> Thanks for the response. >>>=20 >>> $ couchdb -V >>> couchdb - Apache CouchDB 0.10.1 >>>=20 >>> Judging by the CouchDB downloads >>> page, >>> I'm on the latest stable release. I was trying to get a sense of = how far >>> off 0.11 is, so I referred to the road >>> map which >>> looks like it might be out of date, and then to the JIRA >>> issues< >> = https://issues.apache.org/jira/secure/IssueNavigator.jspa?reset=3Dtrue&mod= e=3Dhide&sorter/order=3DDESC&sorter/field=3Dpriority&resolution=3D-1&pid=3D= 12310780&fixfor=3D12313841 >>>=20 >>> for >>> 0.11, which didn't really help either. >>>=20 >>> Is CouchDB a project where it would be ill-advised to run on "edge" = to >> get >>> some 0.11 features early? I'll try just updating SpiderMonkey, as = you >>> suggested, first. >>=20 >> You could also try applying this 1 line patch: >>=20 >>=20 >> = http://github.com/apache/couchdb/commit/82ff1a2b0a15dbe181221173f3013befab= 68f499 >>=20 >> If you are running from a release package and not source, you'll be = editing >> the file >>=20 >> /usr/local/share/couchdb/server/main.js >>=20 >> (you can tell you're in the right place because it'll say "do not = edit this >> file by hand" at the top. Don't worry about that, it's just warning = that >> your changes will be blown away by future couchdb installs. (which = will have >> the patch) >>=20 >> Let us know how it goes. >>=20 >> Chris >>=20 >>>=20 >>> Thanks much. >>>=20 >>> *Mario*, >>>=20 >>> Also, thanks for the response. As a shot in the dark, I had tried >> parseJSON >>> first to no avail. >>>=20 >>> Thanks again to both, >>> Jim >>>=20 >>>=20 >>> On Mon, Mar 1, 2010 at 6:06 PM, Mario Scheliga = >> wrote: >>>=20 >>>> Hi Jim, >>>>=20 >>>> forget my last answer... sorry just grepped the source.... i think = chris >> is >>>> right! >>>>=20 >>>> greetz >>>>=20 >>>> mario >>>>=20 >>>> Am 01.03.2010 um 23:53 schrieb Jim Garvin: >>>>=20 >>>> Hi All, >>>>>=20 >>>>> I'm trying to do server-side created_at timestamps via CouchDB's >> _updates >>>>> features, but I'm having trouble creating a new document out of = the >> JSON >>>>> passed in the request body. My app doesn't allow updates to = existing >>>>> documents, only "inserts". Here's the very simple _updates = function: >>>>>=20 >>>>> function(doc, req) { >>>>> var newDoc =3D JSON.parse(req.body); >>>>> newDoc.created_at =3D new Date(); >>>>> return [newDoc, "FML"]; >>>>> } >>>>>=20 >>>>> When I POST a document to the appropriate _updates URL, I get an = error >> in >>>>> the log telling me that JSON is not defined: >>>>>=20 >>>>> [info] [<0.30422.5>] OS Process :: function raised error: >> ReferenceError: >>>>> JSON is not defined >>>>>=20 >>>>> I wasn't able to find much reference on the web aside from: >>>>>=20 >>>>>=20 >> = http://wiki.apache.org/couchdb/How_to_intercept_document_updates_and_perfo= rm_additional_server-side_processing >>>>> http://www.mikealrogers.com/archives/737 >>>>>=20 >>>>> In the mikealrogers.com post, the author uses JSON in his = function, >> but >>>>> obviously I'm having problems with that approach. Does anyone = know >> what a >>>>> proper way to convert the body of the POST a javascript object = would >> be? >>>>> (avoiding eval()). Also, taking a step back, is this the right >> approach >>>>> for setting default values on a new document in CouchDB? >>>>>=20 >>>>> Thanks, >>>>> Jim >>>>>=20 >>>>=20 >>>>=20 >>>> -- >>>> Sourcegarden GmbH HR: B-104357 >>>> Steuernummer: 37/167/21214 USt-ID: DE814784953 >>>> Geschaeftsfuehrer: Mario Scheliga, Rene Otto >>>> Bank: Deutsche Bank, BLZ: 10070024, KTO: 0810929 >>>> Schoenhauser Allee 51, 10437 Berlin >>>>=20 >>>>=20 >>=20 >>=20