Return-Path: Delivered-To: apmail-couchdb-user-archive@www.apache.org Received: (qmail 22284 invoked from network); 21 Feb 2009 00:22:48 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.2) by minotaur.apache.org with SMTP; 21 Feb 2009 00:22:48 -0000 Received: (qmail 43489 invoked by uid 500); 21 Feb 2009 00:22:42 -0000 Delivered-To: apmail-couchdb-user-archive@couchdb.apache.org Received: (qmail 43462 invoked by uid 500); 21 Feb 2009 00:22:41 -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 Delivered-To: moderator for user@couchdb.apache.org Received: (qmail 86207 invoked by uid 99); 19 Feb 2009 13:50:03 -0000 X-ASF-Spam-Status: No, hits=2.2 required=10.0 tests=HTML_MESSAGE,SPF_PASS X-Spam-Check-By: apache.org Received-SPF: pass (athena.apache.org: domain of craig.mcinnes@gmail.com designates 209.85.218.163 as permitted sender) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:mime-version:received:date:message-id:subject :from:to:content-type; bh=8baihEkbgsHjprIstn2z5QPY8m1ukE5NrHoEB4C7Mo0=; b=lVxV66t5/DbwLp+mbH4d3hKQ7ld5WGs2mewCJWUc/IONy6oj6pEyv4wYttnpFhUV1r FZ8Mfp5m5UWlyPp8ayQ3LBhlLRZnLEI3ToItM9INCBiEkd2mjXA7K0D/eLpCzp/OQ6FU rzimwwKiDjk2mZXF5Rhn57i32fz+zEbnDA2LE= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=mime-version:date:message-id:subject:from:to:content-type; b=HiJVQx8r328H4Lp06cKYOsK2b5zSLMmGWDD+xdgYz5wyqhiSWoYJnYI7CrORsq0F1h VzHk4l1ep12L8w84FrYC14lOZBbZccNPSGxJ1LbDdhiTUCO+RrZcafi8xwObHwr5+TCD mD9iUMHzxCNutm9+HX/A03WF10XMzwdqh4R+8= MIME-Version: 1.0 Date: Thu, 19 Feb 2009 13:49:36 +0000 Message-ID: Subject: couchdb-python, calling a permanent view From: Craig McInnes To: user@couchdb.apache.org Content-Type: multipart/alternative; boundary=001636c5b5988fc2a4046345ce37 X-Virus-Checked: Checked by ClamAV on apache.org --001636c5b5988fc2a4046345ce37 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Hi, I'm having difficulty getting results from a permanent view using couchdb-python. I'm not sure this is the correct place to ask. Apologies if it is not. I've successfully called temporary views and stepped through results (just to verify them), but my understanding is that temporary views do not build a permanent b-tree index on the data (which is what I'd really like to be accessing). I created a permanent view a few different ways: - via futon: In Map Function I've added the barebones map fn: function(doc){emit(doc._id, null);} and hit SaveAS, named the view, the view is now accessible via the drop down. - via couchdb-python: view = ViewDefinition('mytest', 'myall', '''function(doc) {emit(doc._id, null);}''') view.get_doc(db) view.sync(db) and this also is accessible via the drop down in futon. - via couchdb-python: class MyDoc(Document): type = TextField() tags = ListField(IntegerField) added = DateTimeField(default=datetime.datetime.now()) myDocByTag = View('mydocbytag', '''function(doc) {emit(doc._id, null);}''') I then create instances of this class and store them using: .store(db) The class instances are correctly stored as documents in couchdb. This view is *not* stored in couchdb (i.e. I can't see it in the drop down in futon). Trying to invoke this view via: res = MyDoc.myDocByTag(db, count=3) print str(res) print dir(res) for r in res: print str(r) returns: {'count': 3}> ['__class__', '__delattr__', '__dict__', '__doc__', '__getattribute__', '__getitem__', '__hash__', '__init__', '__iter__', '__len__', '__module__', '__new__', '__reduce__', '__reduce_ex__', '__repr__', '__setattr__', '__str__', '__weakref__', '_fetch', '_get_offset', '_get_rows', '_get_total_rows', '_offset', '_rows', '_total_rows', 'offset', 'options', 'rows', 'total_rows', 'view'] Traceback (most recent call last): File "ctest.py", line 277, in for r in res: File "/usr/lib/python2.5/site-packages/CouchDB-0.5-py2.5.egg/couchdb/client.py", line 727, in __iter__ File "/usr/lib/python2.5/site-packages/CouchDB-0.5-py2.5.egg/couchdb/client.py", line 744, in _get_rows File "/usr/lib/python2.5/site-packages/CouchDB-0.5-py2.5.egg/couchdb/client.py", line 737, in _fetch File "/usr/lib/python2.5/site-packages/CouchDB-0.5-py2.5.egg/couchdb/client.py", line 627, in _exec File "/usr/lib/python2.5/site-packages/CouchDB-0.5-py2.5.egg/couchdb/client.py", line 832, in get File "/usr/lib/python2.5/site-packages/CouchDB-0.5-py2.5.egg/couchdb/client.py", line 884, in _request Discounting the last view, I can't seem to access the first two via couchdb-python. I've tried: view = db.view('mytest/myall') print str(view) >>> {}> So it's definitely finding the view correctly (otherwise I'd see a: couchdb.client.ResourceNotFound: (u'not_found', u'missing') error). for r in view: print r.id # this prints nothing, there are no rows in view I've tried messing around with the PermanentView class, or invoking the permanent view via the MyDoc class, but no luck. I'm sure I'm missing something simple, but I need some help. Apologies for the long winded email. Cheers, -Craig --001636c5b5988fc2a4046345ce37--