Error with couchdb.mapping documents (load, store)

26 views
Skip to first unread message

Samuel Baldwin

unread,
Sep 22, 2010, 8:51:40 AM9/22/10
to CouchDB-Python
Howdy; just started using CouchDB-Python, but unfortunately I've
already run into an error. When I'm defining a mapping between a
couchdb document and a python object with class, load and store don't
work. I've confirmed (by looping through 'id in db') that I'm actually
connecting to the database and there's actually data there that the
library can read; this only fails with .mapping.

This is what my code looks like, seems pretty straightforward.

>>> from couchdb import Server, Document
>>> from couchdb.mapping import TextField
>>> server = Server()
>>> db = server['opettelukortit']
>>> class Sana(Document):
... suomi = TextField()
... englanti = TextField()
...
>>> s = Sana.load(db, 'da6bd85034c58b2ae1466f9af20016c6')
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
AttributeError: type object 'Sana' has no attribute 'load'
>>>

Matt Goodall

unread,
Sep 22, 2010, 9:25:36 AM9/22/10
to couchdb...@googlegroups.com
Hi Samuel, 

You need to derive your Sana class from the couchdb.*mapping*.Document (asterisks added for emphasis ;-)).

Hope that helps.

- Matt
Reply all
Reply to author
Forward
0 new messages