You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@couchdb.apache.org by "Eli Stevens (Gmail)" <wi...@gmail.com> on 2010/08/13 09:20:55 UTC

[ANN] couchable 0.0.1b1 (Python object to couchdb document mapper)

I'm happy to announce the availability of couchable 0.0.1b1 (don't let
the low revision number fool you; I anticipate this release will
become a positively geriatric 0.1.0 with little significant change ;).

Couchable is an object mapper between Python 2.7 objects and CouchDB.
It tries to provide a "natural" javascript representation of the
original object, in that an object with a "name" attribute will become
a document with a "name" field, etc.  It also attempts to preserve the
python object with high fidelity - sub objects, dictionaries with
tuple keys, sets, etc. are all supported round-trip, though they might
be harder to work with inside of javascript.

An example that only scratches the surface:
>>> import couchable
>>> cdb=couchable.CouchableDb('example')
>>> class SimpleDoc(object):
...     def __init__(self, **kwargs):
...         for key, value in kwargs.items():
...             setattr(self, key, value)
...
>>> a = SimpleDoc(name='AAA')
>>> cdb.store(a)
'main__.SimpleDoc:2a208810-467f-4feb-a5bb-98d0beb1e5e7'

{
   "_id": "main__.SimpleDoc:2a208810-467f-4feb-a5bb-98d0beb1e5e7",
   "_rev": "1-315ed02172dddb449a4ab38e54b8bb85",
   "couchable:": {
       "class": "SimpleDoc",
       "module": "__main__"
   },
   "name": "AAA"
}

Note that only Python 2.7 is supported ATM.  My use cases don't
include 2.6 or lower, but I would be happy to work with someone who
was interested in using couchable on an older version of Python.

API docs, easy_install info, etc:
    http://pypi.python.org/pypi/couchable/

The source for couchable lives at:
    http://github.com/wickedgrey/couchable

Please use the github issue tracker for bugs:
    http://github.com/wickedgrey/couchable/issues

Couchable is built on the Python CouchDB package:
    http://code.google.com/p/couchdb-python/
But has no affiliation with that project.

Feedback of any kind welcome!  :)  In particular, I'd like to know
what needs better examples and/or documentation; it all seems crystal
clear to me...  ;)

Thanks,
Eli

Re: [ANN] couchable 0.0.1b1 (Python object to couchdb document mapper)

Posted by Sivan Greenberg <si...@omniqueue.com>.
There's also a very similar if not almost identical in CouchDBKit as well.

-Sivan

On Fri, Aug 13, 2010 at 10:28 AM, Dirkjan Ochtman <di...@ochtman.nl> wrote:
> On Fri, Aug 13, 2010 at 09:20, Eli Stevens (Gmail) <wi...@gmail.com> wrote:
>> Couchable is built on the Python CouchDB package:
>>    http://code.google.com/p/couchdb-python/
>> But has no affiliation with that project.
>
> This looks a lot like couchdb.mapping that we provide in couchdb-python.
>
> So I wonder why this is different? We'd love to have you help out with
> improving couchdb.mapping if you feel stuff is missing from that!
>
> Cheers,
>
> Dirkjan
>

Re: [ANN] couchable 0.0.1b1 (Python object to couchdb document mapper)

Posted by Rubén Abad <ra...@paradigmatecnologico.com>.
Sorry... missed thread! My apologies.

On Fri, Aug 13, 2010 at 11:43 AM, Rubén Abad <rabad@paradigmatecnologico.com
> wrote:

> desa@CentOS-53-64-minimal:~/Yell/version_32$ telnet localhost 8888
> Trying 127.0.0.1...
> Connected to localhost.
> Escape character is '^]'.
> hotel en el barrio de goya en madrid
> loca:madrid:madrid&oria|tipoEstablecimiento:hotel:|radius:500:|prov::madrid|WHERE:ALO:|prob:0.273118353177909:|barrio:goya:goya|cobertura:0:|distrito::barrio
> de
> salamanca|##loca::madrid|tipoEstablecimiento:hotel:|radius:500:|prov:madrid:madrid|WHERE:ALO:|prob:0.2725130628322:|barrio:goya:goya|cobertura:0:|distrito::barrio
> de
> salamanca|##loca:madrid:madrid&oria|prov::madrid&almeria|WHERE:ALO:|tipoEstablecimiento:hotel:|prob:0.227490540086524:|radius:500:|wayName:goya:|cobertura:0:|##loca:goya:guntin|prov::lugo|WHERE:ALO:|tipoEstablecimiento:hotel:|prob:0.226878043903366:|radius:500:|cobertura:0:|##
> ##EndConnection##
> Connection closed by foreign host.
> desa@CentOS-53-64-minimal:~/Yell/version_32$ telnet localhost 8888
> Trying 127.0.0.1...
> Connected to localhost.
> Escape character is '^]'.
> centro medico reconocimiento
> nomb:centro medico
> reconocimiento:|WHERE:PAOL:|prob:0.377622377622378:|cobertura:0:|##WHERE:PAOL:|prob:0.335664335664336:|activ:centro
> medico reconocimiento:|cobertura:0:|##nomb:centro
> medico:|WHERE:PAOL:|prob:0.286713286713287:|activ:reconocimiento:|cobertura:0:|##
>
> ##EndConnection##
> Connection closed by foreign host.
> desa@CentOS-53-64-minimal:~/Yell/version_32$ telnet localhost 8888
> Trying 127.0.0.1...
> Connected to localhost.
> Escape character is '^]'.
> hotel en el barrio de goya en madrid
> loca:madrid:madrid&oria|tipoEstablecimiento:hotel:|radius:500:|prov::madrid|WHERE:ALO:|prob:0.273118353177909:|barrio:goya:goya|cobertura:0:|distrito::barrio
> de
> salamanca|##loca::madrid|tipoEstablecimiento:hotel:|radius:500:|prov:madrid:madrid|WHERE:ALO:|prob:0.2725130628322:|barrio:goya:goya|cobertura:0:|distrito::barrio
> de
> salamanca|##loca:madrid:madrid&oria|prov::madrid&almeria|WHERE:ALO:|tipoEstablecimiento:hotel:|prob:0.227490540086524:|radius:500:|wayName:goya:|cobertura:0:|##loca:goya:guntin|prov::lugo|WHERE:ALO:|tipoEstablecimiento:hotel:|prob:0.226878043903366:|radius:500:|cobertura:0:|##
> ##EndConnection##
> Connection closed by foreign host.
>
> On Fri, Aug 13, 2010 at 11:40 AM, Rubén Abad <
> rabad@paradigmatecnologico.com> wrote:
>
>> desa@CentOS-53-64-minimal:~/Yell/version_32$ telnet localhost 8888
>> Trying 127.0.0.1...
>> Connected to localhost.
>> Escape character is '^]'.
>> hotel en el barrio de goya en madrid
>> loca:madrid:madrid&oria|tipoEstablecimiento:hotel:|radius:500:|prov::madrid|WHERE:ALO:|prob:0.273118353177909:|barrio:goya:goya|cobertura:0:|distrito::barrio
>> de
>> salamanca|##loca::madrid|tipoEstablecimiento:hotel:|radius:500:|prov:madrid:madrid|WHERE:ALO:|prob:0.2725130628322:|barrio:goya:goya|cobertura:0:|distrito::barrio
>> de
>> salamanca|##loca:madrid:madrid&oria|prov::madrid&almeria|WHERE:ALO:|tipoEstablecimiento:hotel:|prob:0.227490540086524:|radius:500:|wayName:goya:|cobertura:0:|##loca:goya:guntin|prov::lugo|WHERE:ALO:|tipoEstablecimiento:hotel:|prob:0.226878043903366:|radius:500:|cobertura:0:|##
>> ##EndConnection##
>> Connection closed by foreign host.
>>
>>
>> Se me está pegando el mongolismo de Hell... aquí va sin el ^M
>>
>>
>> On Fri, Aug 13, 2010 at 11:39 AM, Rubén Abad <
>> rabad@paradigmatecnologico.com> wrote:
>>
>>> desa@CentOS-53-64-minimal:~/Yell/version_32$ telnet localhost 8888
>>> Trying 127.0.0.1...
>>> Connected to localhost.
>>> Escape character is '^]'.
>>> hotel en el barrio de goya en madrid^M
>>> loca:madrid:madrid&oria|tipoEstablecimiento:hotel:|radius:500:|prov::madrid|WHERE:ALO:|prob:0.273118353177909:|barrio:goya:goya|cobertura:0:|distrito::barrio
>>> de
>>> salamanca|##loca::madrid|tipoEstablecimiento:hotel:|radius:500:|prov:madrid:madrid|WHERE:ALO:|prob:0.2725130628322:|barrio:goya:goya|cobertura:0:|distrito::barrio
>>> de
>>> salamanca|##loca:madrid:madrid&oria|prov::madrid&almeria|WHERE:ALO:|tipoEstablecimiento:hotel:|prob:0.227490540086524:|radius:500:|wayName:goya:|cobertura:0:|##loca:goya:guntin|prov::lugo|WHERE:ALO:|tipoEstablecimiento:hotel:|prob:0.226878043903366:|radius:500:|cobertura:0:|##
>>> ##EndConnection##
>>> Connection closed by foreign host.
>>>
>>>
>>> On Fri, Aug 13, 2010 at 11:17 AM, Dirkjan Ochtman <di...@ochtman.nl>wrote:
>>>
>>>> On Fri, Aug 13, 2010 at 10:54, Eli Stevens (Gmail) <
>>>> wickedgrey@gmail.com> wrote:
>>>> > Philosophically, it feels like couchdb.mapping and couchdbkit are
>>>> > trying to take CouchDB documents and expose them to Python.  Couchable
>>>> > aims to go the other way - take arbitrary Python objects and store
>>>> > them in CouchDB (a poorly-stated goal of couchable is that *any*
>>>> > Python object should be able to round-trip cleanly).  This results in
>>>> > objects like 'a' in the following being able to round-trip cleanly, at
>>>> > the expense of a somewhat loud document in CouchDB:
>>>>
>>>> Okay, that sounds sensible, and I think that would be inappropriate
>>>> for couchdb-python. :)
>>>>
>>>> Thanks for clarifying.
>>>>
>>>> Cheers,
>>>>
>>>> Dirkjan
>>>>
>>>
>>>
>>>
>>> --
>>> Rubén Abad Agulló
>>>
>>> http://www.paradigmatecnologico.com
>>> Avenida de Europa, 26. Ática 5. 3ª Planta
>>> 28224 Pozuelo de Alarcón
>>>
>>
>>
>>
>> --
>> Rubén Abad Agulló
>>
>> http://www.paradigmatecnologico.com
>> Avenida de Europa, 26. Ática 5. 3ª Planta
>> 28224 Pozuelo de Alarcón
>>
>
>
>
> --
> Rubén Abad Agulló
>
> http://www.paradigmatecnologico.com
> Avenida de Europa, 26. Ática 5. 3ª Planta
> 28224 Pozuelo de Alarcón
>



-- 
Rubén Abad Agulló

http://www.paradigmatecnologico.com
Avenida de Europa, 26. Ática 5. 3ª Planta
28224 Pozuelo de Alarcón

Re: [ANN] couchable 0.0.1b1 (Python object to couchdb document mapper)

Posted by Rubén Abad <ra...@paradigmatecnologico.com>.
desa@CentOS-53-64-minimal:~/Yell/version_32$ telnet localhost 8888
Trying 127.0.0.1...
Connected to localhost.
Escape character is '^]'.
hotel en el barrio de goya en madrid
loca:madrid:madrid&oria|tipoEstablecimiento:hotel:|radius:500:|prov::madrid|WHERE:ALO:|prob:0.273118353177909:|barrio:goya:goya|cobertura:0:|distrito::barrio
de
salamanca|##loca::madrid|tipoEstablecimiento:hotel:|radius:500:|prov:madrid:madrid|WHERE:ALO:|prob:0.2725130628322:|barrio:goya:goya|cobertura:0:|distrito::barrio
de
salamanca|##loca:madrid:madrid&oria|prov::madrid&almeria|WHERE:ALO:|tipoEstablecimiento:hotel:|prob:0.227490540086524:|radius:500:|wayName:goya:|cobertura:0:|##loca:goya:guntin|prov::lugo|WHERE:ALO:|tipoEstablecimiento:hotel:|prob:0.226878043903366:|radius:500:|cobertura:0:|##
##EndConnection##
Connection closed by foreign host.
desa@CentOS-53-64-minimal:~/Yell/version_32$ telnet localhost 8888
Trying 127.0.0.1...
Connected to localhost.
Escape character is '^]'.
centro medico reconocimiento
nomb:centro medico
reconocimiento:|WHERE:PAOL:|prob:0.377622377622378:|cobertura:0:|##WHERE:PAOL:|prob:0.335664335664336:|activ:centro
medico reconocimiento:|cobertura:0:|##nomb:centro
medico:|WHERE:PAOL:|prob:0.286713286713287:|activ:reconocimiento:|cobertura:0:|##
##EndConnection##
Connection closed by foreign host.
desa@CentOS-53-64-minimal:~/Yell/version_32$ telnet localhost 8888
Trying 127.0.0.1...
Connected to localhost.
Escape character is '^]'.
hotel en el barrio de goya en madrid
loca:madrid:madrid&oria|tipoEstablecimiento:hotel:|radius:500:|prov::madrid|WHERE:ALO:|prob:0.273118353177909:|barrio:goya:goya|cobertura:0:|distrito::barrio
de
salamanca|##loca::madrid|tipoEstablecimiento:hotel:|radius:500:|prov:madrid:madrid|WHERE:ALO:|prob:0.2725130628322:|barrio:goya:goya|cobertura:0:|distrito::barrio
de
salamanca|##loca:madrid:madrid&oria|prov::madrid&almeria|WHERE:ALO:|tipoEstablecimiento:hotel:|prob:0.227490540086524:|radius:500:|wayName:goya:|cobertura:0:|##loca:goya:guntin|prov::lugo|WHERE:ALO:|tipoEstablecimiento:hotel:|prob:0.226878043903366:|radius:500:|cobertura:0:|##
##EndConnection##
Connection closed by foreign host.

On Fri, Aug 13, 2010 at 11:40 AM, Rubén Abad <rabad@paradigmatecnologico.com
> wrote:

> desa@CentOS-53-64-minimal:~/Yell/version_32$ telnet localhost 8888
> Trying 127.0.0.1...
> Connected to localhost.
> Escape character is '^]'.
> hotel en el barrio de goya en madrid
> loca:madrid:madrid&oria|tipoEstablecimiento:hotel:|radius:500:|prov::madrid|WHERE:ALO:|prob:0.273118353177909:|barrio:goya:goya|cobertura:0:|distrito::barrio
> de
> salamanca|##loca::madrid|tipoEstablecimiento:hotel:|radius:500:|prov:madrid:madrid|WHERE:ALO:|prob:0.2725130628322:|barrio:goya:goya|cobertura:0:|distrito::barrio
> de
> salamanca|##loca:madrid:madrid&oria|prov::madrid&almeria|WHERE:ALO:|tipoEstablecimiento:hotel:|prob:0.227490540086524:|radius:500:|wayName:goya:|cobertura:0:|##loca:goya:guntin|prov::lugo|WHERE:ALO:|tipoEstablecimiento:hotel:|prob:0.226878043903366:|radius:500:|cobertura:0:|##
> ##EndConnection##
> Connection closed by foreign host.
>
>
> Se me está pegando el mongolismo de Hell... aquí va sin el ^M
>
>
> On Fri, Aug 13, 2010 at 11:39 AM, Rubén Abad <
> rabad@paradigmatecnologico.com> wrote:
>
>> desa@CentOS-53-64-minimal:~/Yell/version_32$ telnet localhost 8888
>> Trying 127.0.0.1...
>> Connected to localhost.
>> Escape character is '^]'.
>> hotel en el barrio de goya en madrid^M
>> loca:madrid:madrid&oria|tipoEstablecimiento:hotel:|radius:500:|prov::madrid|WHERE:ALO:|prob:0.273118353177909:|barrio:goya:goya|cobertura:0:|distrito::barrio
>> de
>> salamanca|##loca::madrid|tipoEstablecimiento:hotel:|radius:500:|prov:madrid:madrid|WHERE:ALO:|prob:0.2725130628322:|barrio:goya:goya|cobertura:0:|distrito::barrio
>> de
>> salamanca|##loca:madrid:madrid&oria|prov::madrid&almeria|WHERE:ALO:|tipoEstablecimiento:hotel:|prob:0.227490540086524:|radius:500:|wayName:goya:|cobertura:0:|##loca:goya:guntin|prov::lugo|WHERE:ALO:|tipoEstablecimiento:hotel:|prob:0.226878043903366:|radius:500:|cobertura:0:|##
>> ##EndConnection##
>> Connection closed by foreign host.
>>
>>
>> On Fri, Aug 13, 2010 at 11:17 AM, Dirkjan Ochtman <di...@ochtman.nl>wrote:
>>
>>> On Fri, Aug 13, 2010 at 10:54, Eli Stevens (Gmail) <wi...@gmail.com>
>>> wrote:
>>> > Philosophically, it feels like couchdb.mapping and couchdbkit are
>>> > trying to take CouchDB documents and expose them to Python.  Couchable
>>> > aims to go the other way - take arbitrary Python objects and store
>>> > them in CouchDB (a poorly-stated goal of couchable is that *any*
>>> > Python object should be able to round-trip cleanly).  This results in
>>> > objects like 'a' in the following being able to round-trip cleanly, at
>>> > the expense of a somewhat loud document in CouchDB:
>>>
>>> Okay, that sounds sensible, and I think that would be inappropriate
>>> for couchdb-python. :)
>>>
>>> Thanks for clarifying.
>>>
>>> Cheers,
>>>
>>> Dirkjan
>>>
>>
>>
>>
>> --
>> Rubén Abad Agulló
>>
>> http://www.paradigmatecnologico.com
>> Avenida de Europa, 26. Ática 5. 3ª Planta
>> 28224 Pozuelo de Alarcón
>>
>
>
>
> --
> Rubén Abad Agulló
>
> http://www.paradigmatecnologico.com
> Avenida de Europa, 26. Ática 5. 3ª Planta
> 28224 Pozuelo de Alarcón
>



-- 
Rubén Abad Agulló

http://www.paradigmatecnologico.com
Avenida de Europa, 26. Ática 5. 3ª Planta
28224 Pozuelo de Alarcón

Re: [ANN] couchable 0.0.1b1 (Python object to couchdb document mapper)

Posted by Rubén Abad <ra...@paradigmatecnologico.com>.
desa@CentOS-53-64-minimal:~/Yell/version_32$ telnet localhost 8888
Trying 127.0.0.1...
Connected to localhost.
Escape character is '^]'.
hotel en el barrio de goya en madrid
loca:madrid:madrid&oria|tipoEstablecimiento:hotel:|radius:500:|prov::madrid|WHERE:ALO:|prob:0.273118353177909:|barrio:goya:goya|cobertura:0:|distrito::barrio
de
salamanca|##loca::madrid|tipoEstablecimiento:hotel:|radius:500:|prov:madrid:madrid|WHERE:ALO:|prob:0.2725130628322:|barrio:goya:goya|cobertura:0:|distrito::barrio
de
salamanca|##loca:madrid:madrid&oria|prov::madrid&almeria|WHERE:ALO:|tipoEstablecimiento:hotel:|prob:0.227490540086524:|radius:500:|wayName:goya:|cobertura:0:|##loca:goya:guntin|prov::lugo|WHERE:ALO:|tipoEstablecimiento:hotel:|prob:0.226878043903366:|radius:500:|cobertura:0:|##
##EndConnection##
Connection closed by foreign host.


Se me está pegando el mongolismo de Hell... aquí va sin el ^M

On Fri, Aug 13, 2010 at 11:39 AM, Rubén Abad <rabad@paradigmatecnologico.com
> wrote:

> desa@CentOS-53-64-minimal:~/Yell/version_32$ telnet localhost 8888
> Trying 127.0.0.1...
> Connected to localhost.
> Escape character is '^]'.
> hotel en el barrio de goya en madrid^M
> loca:madrid:madrid&oria|tipoEstablecimiento:hotel:|radius:500:|prov::madrid|WHERE:ALO:|prob:0.273118353177909:|barrio:goya:goya|cobertura:0:|distrito::barrio
> de
> salamanca|##loca::madrid|tipoEstablecimiento:hotel:|radius:500:|prov:madrid:madrid|WHERE:ALO:|prob:0.2725130628322:|barrio:goya:goya|cobertura:0:|distrito::barrio
> de
> salamanca|##loca:madrid:madrid&oria|prov::madrid&almeria|WHERE:ALO:|tipoEstablecimiento:hotel:|prob:0.227490540086524:|radius:500:|wayName:goya:|cobertura:0:|##loca:goya:guntin|prov::lugo|WHERE:ALO:|tipoEstablecimiento:hotel:|prob:0.226878043903366:|radius:500:|cobertura:0:|##
> ##EndConnection##
> Connection closed by foreign host.
>
>
> On Fri, Aug 13, 2010 at 11:17 AM, Dirkjan Ochtman <di...@ochtman.nl>wrote:
>
>> On Fri, Aug 13, 2010 at 10:54, Eli Stevens (Gmail) <wi...@gmail.com>
>> wrote:
>> > Philosophically, it feels like couchdb.mapping and couchdbkit are
>> > trying to take CouchDB documents and expose them to Python.  Couchable
>> > aims to go the other way - take arbitrary Python objects and store
>> > them in CouchDB (a poorly-stated goal of couchable is that *any*
>> > Python object should be able to round-trip cleanly).  This results in
>> > objects like 'a' in the following being able to round-trip cleanly, at
>> > the expense of a somewhat loud document in CouchDB:
>>
>> Okay, that sounds sensible, and I think that would be inappropriate
>> for couchdb-python. :)
>>
>> Thanks for clarifying.
>>
>> Cheers,
>>
>> Dirkjan
>>
>
>
>
> --
> Rubén Abad Agulló
>
> http://www.paradigmatecnologico.com
> Avenida de Europa, 26. Ática 5. 3ª Planta
> 28224 Pozuelo de Alarcón
>



-- 
Rubén Abad Agulló

http://www.paradigmatecnologico.com
Avenida de Europa, 26. Ática 5. 3ª Planta
28224 Pozuelo de Alarcón

Re: [ANN] couchable 0.0.1b1 (Python object to couchdb document mapper)

Posted by Rubén Abad <ra...@paradigmatecnologico.com>.
desa@CentOS-53-64-minimal:~/Yell/version_32$ telnet localhost 8888
Trying 127.0.0.1...
Connected to localhost.
Escape character is '^]'.
hotel en el barrio de goya en madrid^M
loca:madrid:madrid&oria|tipoEstablecimiento:hotel:|radius:500:|prov::madrid|WHERE:ALO:|prob:0.273118353177909:|barrio:goya:goya|cobertura:0:|distrito::barrio
de
salamanca|##loca::madrid|tipoEstablecimiento:hotel:|radius:500:|prov:madrid:madrid|WHERE:ALO:|prob:0.2725130628322:|barrio:goya:goya|cobertura:0:|distrito::barrio
de
salamanca|##loca:madrid:madrid&oria|prov::madrid&almeria|WHERE:ALO:|tipoEstablecimiento:hotel:|prob:0.227490540086524:|radius:500:|wayName:goya:|cobertura:0:|##loca:goya:guntin|prov::lugo|WHERE:ALO:|tipoEstablecimiento:hotel:|prob:0.226878043903366:|radius:500:|cobertura:0:|##
##EndConnection##
Connection closed by foreign host.

On Fri, Aug 13, 2010 at 11:17 AM, Dirkjan Ochtman <di...@ochtman.nl>wrote:

> On Fri, Aug 13, 2010 at 10:54, Eli Stevens (Gmail) <wi...@gmail.com>
> wrote:
> > Philosophically, it feels like couchdb.mapping and couchdbkit are
> > trying to take CouchDB documents and expose them to Python.  Couchable
> > aims to go the other way - take arbitrary Python objects and store
> > them in CouchDB (a poorly-stated goal of couchable is that *any*
> > Python object should be able to round-trip cleanly).  This results in
> > objects like 'a' in the following being able to round-trip cleanly, at
> > the expense of a somewhat loud document in CouchDB:
>
> Okay, that sounds sensible, and I think that would be inappropriate
> for couchdb-python. :)
>
> Thanks for clarifying.
>
> Cheers,
>
> Dirkjan
>



-- 
Rubén Abad Agulló

http://www.paradigmatecnologico.com
Avenida de Europa, 26. Ática 5. 3ª Planta
28224 Pozuelo de Alarcón

Re: [ANN] couchable 0.0.1b1 (Python object to couchdb document mapper)

Posted by "Eli Stevens (Gmail)" <wi...@gmail.com>.
On Fri, Aug 13, 2010 at 3:08 AM, Benoit Chesneau <bc...@gmail.com> wrote:
> You may be interrested in  http://github.com/Xjs/couchdbkit-mapper then :)

Thanks for the link.  :)  The approach (make a dynamic subclass of
both the class you want and of Document) is nice.

Unfortunately, I wasn't able to get the code to work.  I'm using a
recent install of couchdbkit; after commenting out the following two
seemingly unnecessary lines from the unit tests:

#from httplib2 import Http
#from restclient.transport import HTTPLib2Transport

I get the following:

$ python -m unittest discover -vbs .
testMapping (test_mapper.MapperTestCase) ... ERROR
testViewResults (test_mapper.MapperTestCase) ... ERROR

======================================================================
ERROR: testMapping (test_mapper.MapperTestCase)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/Users/elis/edit/opensource/couchdbkit/mapper/test_mapper.py",
line 54, in setUp
    self.db = Mapper(db_name, server=self.server)
  File "/Users/elis/edit/opensource/couchdbkit/mapper/mapper.py", line
106, in __init__
    super(Mapper, self).__init__(*args, **parameters)
  File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/couchdbkit-0.4.11-py2.7.egg/couchdbkit/client.py",
line 238, in __init__
    self.server_uri, self.dbname = uri.rsplit("/", 1)
ValueError: need more than 1 value to unpack

======================================================================
ERROR: testViewResults (test_mapper.MapperTestCase)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/Users/elis/edit/opensource/couchdbkit/mapper/test_mapper.py",
line 54, in setUp
    self.db = Mapper(db_name, server=self.server)
  File "/Users/elis/edit/opensource/couchdbkit/mapper/mapper.py", line
106, in __init__
    super(Mapper, self).__init__(*args, **parameters)
  File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/couchdbkit-0.4.11-py2.7.egg/couchdbkit/client.py",
line 238, in __init__
    self.server_uri, self.dbname = uri.rsplit("/", 1)
ValueError: need more than 1 value to unpack

----------------------------------------------------------------------
Ran 2 tests in 0.055s

FAILED (errors=2)

Does anyone know if Xjs is a member of this mailing list, and/or is
interested in bug reports?

Eli

Re: [ANN] couchable 0.0.1b1 (Python object to couchdb document mapper)

Posted by Benoit Chesneau <bc...@gmail.com>.
On Fri, Aug 13, 2010 at 11:17 AM, Dirkjan Ochtman <di...@ochtman.nl> wrote:
> On Fri, Aug 13, 2010 at 10:54, Eli Stevens (Gmail) <wi...@gmail.com> wrote:
>> Philosophically, it feels like couchdb.mapping and couchdbkit are
>> trying to take CouchDB documents and expose them to Python.  Couchable
>> aims to go the other way - take arbitrary Python objects and store
>> them in CouchDB (a poorly-stated goal of couchable is that *any*
>> Python object should be able to round-trip cleanly).  This results in
>> objects like 'a' in the following being able to round-trip cleanly, at
>> the expense of a somewhat loud document in CouchDB:
>
You may be interrested in  http://github.com/Xjs/couchdbkit-mapper then :)

- benoit

Re: [ANN] couchable 0.0.1b1 (Python object to couchdb document mapper)

Posted by Dirkjan Ochtman <di...@ochtman.nl>.
On Fri, Aug 13, 2010 at 10:54, Eli Stevens (Gmail) <wi...@gmail.com> wrote:
> Philosophically, it feels like couchdb.mapping and couchdbkit are
> trying to take CouchDB documents and expose them to Python.  Couchable
> aims to go the other way - take arbitrary Python objects and store
> them in CouchDB (a poorly-stated goal of couchable is that *any*
> Python object should be able to round-trip cleanly).  This results in
> objects like 'a' in the following being able to round-trip cleanly, at
> the expense of a somewhat loud document in CouchDB:

Okay, that sounds sensible, and I think that would be inappropriate
for couchdb-python. :)

Thanks for clarifying.

Cheers,

Dirkjan

Re: [ANN] couchable 0.0.1b1 (Python object to couchdb document mapper)

Posted by "Eli Stevens (Gmail)" <wi...@gmail.com>.
Hello!  :)

I agree that there are a number of similarities, and certainly
wouldn't have a problem with consolidating effort.  However, I've got
a number of use cases that seem to run directly counter to how both
couchdb.mapping and couchdbkit have been structured.  I certainly
wouldn't want to try and dictate how those projects should evolve,
just because my use cases are different!

>From what I could tell from the couchdb.mapping and couchdbkit
documentation (I will admit to basing this solely on the docs; if
there's more to these packages than I realize, I'd love to find out
more), I see three main points of differentiation for couchable:

- No requirement to inherit from a fixed Document base class.  This is
helpful if 3rd party objects need to be stored in CouchDB.
- No requirement to specify the schema in advance.  couchdbkit has
dynamic properties; I couldn't tell what would happen to unspecified
fields in couchdb.mapping.
- Can roundtrip data through CouchDB that doesn't have a native JSON
representation (example: dicts with tuple keys, arbitrary
sub-objects).

There are also a few minor features, like mapping certain types to
attachments, the ability for the end user to specify conversion
routines for types that don't work out of the box (ie. don't have a
__dict__), and the ability to save and load an interlinked object
hierarchy (a is a doc that has a ref to b, which is also a doc, etc.).

Philosophically, it feels like couchdb.mapping and couchdbkit are
trying to take CouchDB documents and expose them to Python.  Couchable
aims to go the other way - take arbitrary Python objects and store
them in CouchDB (a poorly-stated goal of couchable is that *any*
Python object should be able to round-trip cleanly).  This results in
objects like 'a' in the following being able to round-trip cleanly, at
the expense of a somewhat loud document in CouchDB:

>>> import couchable
>>> cdb=couchable.CouchableDb('example')
>>> class SimpleDoc(couchable.CouchableDoc):
...     def __init__(self, **kwargs):
...         for key, value in kwargs.items():
...             setattr(self, key, value)
...
>>> a = SimpleDoc(name='AAA')
>>> a.dict_ = {'foo':'FOO', 123:'bar', (45, 67):'baz'}
>>> cdb.store(a)
'main__.SimpleDoc:2a208810-467f-4feb-a5bb-98d0beb1e5e7'

{
   "_id": "main__.SimpleDoc:2a208810-467f-4feb-a5bb-98d0beb1e5e7",
   "_rev": "7-4706c617a5f8900956c76ecb6f2e2daa",
   "couchable:": {
       "keys": {
           "couchable:key:tuple:(45, 67)": {
               "couchable:": {
                   "args": [[45, 67]],
                   "class": "tuple",
                   "module": "__builtin__",
                   "kwargs": {
                   }
               }
           }
       },
       "class": "SimpleDoc",
       "module": "__main__"
   },
   "dict_": {
       "couchable:key:tuple:(45, 67)": "baz",
       "foo": "FOO",
       "couchable:repr:int:123": "bar"
   },
   "name": "AAA"
}

Again, if I've misunderstood the capabilities of either of these
projects, please don't hesitate to correct me!  :)  It's getting late
here, but I'll try and check back before work tomorrow.

Cheers,
Eli


On Fri, Aug 13, 2010 at 12:28 AM, Dirkjan Ochtman <di...@ochtman.nl> wrote:
> On Fri, Aug 13, 2010 at 09:20, Eli Stevens (Gmail) <wi...@gmail.com> wrote:
>> Couchable is built on the Python CouchDB package:
>>    http://code.google.com/p/couchdb-python/
>> But has no affiliation with that project.
>
> This looks a lot like couchdb.mapping that we provide in couchdb-python.
>
> So I wonder why this is different? We'd love to have you help out with
> improving couchdb.mapping if you feel stuff is missing from that!
>
> Cheers,
>
> Dirkjan

Re: [ANN] couchable 0.0.1b1 (Python object to couchdb document mapper)

Posted by Dirkjan Ochtman <di...@ochtman.nl>.
On Fri, Aug 13, 2010 at 09:20, Eli Stevens (Gmail) <wi...@gmail.com> wrote:
> Couchable is built on the Python CouchDB package:
>    http://code.google.com/p/couchdb-python/
> But has no affiliation with that project.

This looks a lot like couchdb.mapping that we provide in couchdb-python.

So I wonder why this is different? We'd love to have you help out with
improving couchdb.mapping if you feel stuff is missing from that!

Cheers,

Dirkjan