From user-return-15589-apmail-couchdb-user-archive=couchdb.apache.org@couchdb.apache.org Fri Apr 01 18:08:49 2011 Return-Path: Delivered-To: apmail-couchdb-user-archive@www.apache.org Received: (qmail 52808 invoked from network); 1 Apr 2011 18:08:49 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.3) by minotaur.apache.org with SMTP; 1 Apr 2011 18:08:49 -0000 Received: (qmail 28311 invoked by uid 500); 1 Apr 2011 18:08:48 -0000 Delivered-To: apmail-couchdb-user-archive@couchdb.apache.org Received: (qmail 28268 invoked by uid 500); 1 Apr 2011 18:08:47 -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 28260 invoked by uid 99); 1 Apr 2011 18:08:47 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 01 Apr 2011 18:08:47 +0000 X-ASF-Spam-Status: No, hits=-0.7 required=5.0 tests=FREEMAIL_FROM,RCVD_IN_DNSWL_LOW,SPF_PASS,T_TO_NO_BRKTS_FREEMAIL,WEIRD_PORT X-Spam-Check-By: apache.org Received-SPF: pass (nike.apache.org: domain of luismiguelferreirasilva@gmail.com designates 209.85.214.180 as permitted sender) Received: from [209.85.214.180] (HELO mail-iw0-f180.google.com) (209.85.214.180) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 01 Apr 2011 18:08:41 +0000 Received: by iwn6 with SMTP id 6so5418650iwn.11 for ; Fri, 01 Apr 2011 11:08:20 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:mime-version:in-reply-to:references:from:date :message-id:subject:to:content-type:content-transfer-encoding; bh=dJL2UjTcfOSFOacaMwRuDrqNbKnBUSY1lbCTc6ma6Ns=; b=IPkogZqr+fXDoNqe+KtWSyU3JlgJyMld8VR/iB52DGomL8MaHhTHoQlAbDyt/uOg6X J0VSpaXOWefat2Voma9yU6JCUcq5Qa3L3nI6Rh7IpZskMcppMMixnAvdiCp/v8rCJlxw jappp2O7YrEz56ZZPG9+ahBzW3kLvSAXIqLS8= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :content-type:content-transfer-encoding; b=nBS6kywdz/ur1pr1xyxO6hwz+j92o7e18K85vtbADYX6yUSLshCQtoldcIlQoJ/AoE VKh1aFbDTFERyOvokhs1eS/9LM9pLKAWaqCo1sXdkYc1virgvbWwRn0Gupt25Ctc3wH0 4OXO11Bpl4xkqVVW6V4Yr+dqbMykv06VQ0BZM= Received: by 10.231.92.15 with SMTP id p15mr4248419ibm.153.1301681300234; Fri, 01 Apr 2011 11:08:20 -0700 (PDT) MIME-Version: 1.0 Received: by 10.231.37.195 with HTTP; Fri, 1 Apr 2011 11:08:00 -0700 (PDT) In-Reply-To: <1301642387.21215.248.camel@meerkat.green.sophos> References: <1301642387.21215.248.camel@meerkat.green.sophos> From: Luis Miguel Silva Date: Fri, 1 Apr 2011 12:08:00 -0600 Message-ID: Subject: Re: [somewhat off-topic] Any good perl modules for consuming CouchDB? Having trouble with Perl's CouchDB::Client To: user@couchdb.apache.org Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable X-Virus-Checked: Checked by ClamAV on apache.org Dear Paul (and others), Thanks for your sample code. I believe i found the problem (though i do not know how to solve it :oP). So here is how my setup looks: - 1 couchDB at x06.ac with authentication - here is how i configured it: (in local.ini) [couch_httpd_auth] secret =3D something [admins] admin =3D something (in default.ini) [httpd] authentication_handlers =3D {couch_httpd_oauth, oauth_authentication_handler}, {couch_httpd_auth, cookie_authentication_handler}, {couch_httpd_auth, default_authentication_handler} Then i created user accounts directly via CouchDB's web interface (i can't remember the name right now :oP) and have set roles in "mydatabase" so that one user can read and the other one can write. (though i don't think it is important since i'm trying to access with admin privileges, i thought i would mention it)... - 1 couchDB at xkitten.ac without authentication - both couchDB servers replicate to each other (and that seems to work fine= ) - If i consume the one with authentication, i get that error i showed you: "malformed JSON string, neither array, object, number, string or atom, at character offset 0 (before "\n wrote: > On Thu, 2011-03-31 at 18:28 +0100, Luis Miguel Silva wrote: >> Dear all, >> >> Sorry for yet another email but i was wondering if anybody in the >> community has had good experiences querying views from Perl? >> I'm trying CouchDB::Client perl module but i simply cannot consume a >> view i created... >> >> =A0 =A0 =A0 =A0 my $db =3D $c->newDB('mydatabase'); >> =A0 =A0 =A0 =A0 print "puff\n"; >> =A0 =A0 =A0 =A0 my $view =3D $db->newDesignDoc('_design/testviewdoc')->r= etrieve; >> =A0 =A0 =A0 =A0 my $result =3D try { >> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 $view->queryView('testviewname'); >> =A0 =A0 =A0 =A0 } catch { >> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 die "Could not query view"; >> =A0 =A0 =A0 =A0 }; > > I tried you code, after a few tweaks, in my environment against one of > my databases and it works fine. > > The entire piece of perl I ran was this: > > use CouchDB::Client; > use Try::Tiny; > use strict; > use warnings; > my $c =3D CouchDB::Client->new( uri =3D> "http://uk-couch:5984"); > my $db =3D $c->newDB('ddb'); > print "puff\n"; > my $view =3D $db->newDesignDoc('_design/conflicts')->retrieve; > my $result =3D try { > =A0 =A0 =A0 =A0$view->queryView('docs'); > } catch { > =A0 =A0 =A0 =A0die "Could not query view"; > }; > > Make sure you are using CouchDB::Client version 0.09. I have found older > versions to be a bit buggy. I haven't yet had any issues with version > 0.09. > > You might find it useful to add the following lines after the my $c =3D .= . > > $c->{ua}->add_handler("request_send", =A0sub { shift->dump; return }); > $c->{ua}->add_handler("response_done", sub { shift->dump; return }); > > Then you can see the entire requests and responses which could give you > more clues about what is going wrong. > > So far I've found CouchDB::Client to be the best module for Perl. > Net::CouchDB seems to have disappeared and AnyEvent::CouchDB didn't work > for me (threw errors in the AnyEvent::HTTP module) and might be a > paradigm you don't want to use. > > > Sophos Limited, The Pentagon, Abingdon Science Park, Abingdon, OX14 3YP, = United Kingdom. > Company Reg No 2096520. VAT Reg No GB 991 2418 08. >