[Tutor] couchdb.mapping 'Document' class
Knacktus
knacktus at googlemail.com
Tue Mar 1 21:39:34 CET 2011
Am 01.03.2011 16:19, schrieb Emanuel Lauria:
> Hi everyone,
>
> I'm trying to map a couchdb document to a python object using
> couchdb.mapping. I'm stuck in the very first part were it says I should
> declare a Python class that inherits from the 'Document'.. Where does
> this 'Document' superclass comes from? I can't resolve it. Or do I have
> to create it? How? Could someone point me in to the right direction?
>
> >>> import couchdb
>
> >>> class Person(Document):
> ... name = TextField()
> ...
> Traceback (most recent call last):
> File "<stdin>", line 1, in <module>
> NameError: name 'Document' is not defined
>
It looks like the class Document is located in the module couchdb.client
(it's chapter 3.3).
This should work:
import couchdb.client
class Person(couchdb.client.Document):
...
HTH
Jan
>
> Thanks for your help, and please forgive me if im too n00b in this. I
> havent found any documentation except
> http://packages.python.org/CouchDB/mapping.html which is not enough.
>
> Thanks
>
>
>
> _______________________________________________
> Tutor maillist - Tutor at python.org
> To unsubscribe or change subscription options:
> http://mail.python.org/mailman/listinfo/tutor
More information about the Tutor
mailing list