incubator-couchdb-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Sergey Shepelev <temo...@gmail.com>
Subject Re: Things I can't figure out (load documents from dicts, ...)
Date Sun, 21 Jun 2009 23:22:49 GMT
On Mon, Jun 22, 2009 at 1:42 AM, Thomas Harding <tom@thomas-harding.name> wrote:
>
> Hello,
> I'm a beginner in couchdb and couchdb-python.
>
> And I'm not so experienced in Python...
> nor in English.
>
> I've played with couchdb for two week-ends,  and I'm able now to
> do few things, starting from a script  I found on the ternet (see
> attachment).
>
> I've also added a "login" function to couchdb-python V.05
> "Server" class -- I can post a patch if s.o. is interrested
> (about 10 lines...) --  to be able to connect ([admins] is set
> on my couchdb server).
>
> Howether, I was not able to find a FAQ or an extensive code snippet.
>
> So, I can't figure out some things:
>  * how to set arbitrary properties on whatever(Document) from
>   a  dict (properly Json encoded, obviously: set up   self.__dict__['_data'][key]
= val is not the good way)

What you written is made as self._data[key] = val. If you're not
experienced with python, do not use anything starting with __.

To update document from dict, (remembering that document is much like
a dict), use update method:
self.update({'new key': "new value"})

>  * how to retrieve arbitrary key/values _to_python encoded
>    while  the step above will be done

There is no "python encoded", what do you mean?
couchdb-python already provides you with JSON decoding so you see
couch docs as python dicts.

To get document from database by id, you use

doc = db['id']

that's covered in couchdb-python documentation. Which is in
file:///usr/share/doc/python-couchdb/api/couchdb.client-module.html

P.S. and first of all, this is CouchDB mailing list. Couchdb-python
has separate one on Google Groups.

>
> Thanks anyway for your replies,
> T. Harding
>
>
>

Mime
View raw message