cloudant-labs / cloudant-python

Asynchronous Cloudant / CouchDB interface for Python
http://cloudant-labs.github.io/cloudant-python/
37 stars 17 forks source link

Match `couchdb-python` API where possible #16

Closed BigBlueHat closed 10 years ago

BigBlueHat commented 10 years ago

couchdb-python has the goods on a "Pythonic" API to CouchDB.

I know such things are subjective/opinionated, but barring that, I find matching this API and pulling in the best bits and opportunity for consensus building and easy switching/upgrading when a user moves to Cloudant (both the service and this Python library).

garbados commented 10 years ago

That'd be cool. Wanna make a branch that pulls this off?

garbados commented 10 years ago

For my personal curiosity, what makes couchdb-python pythonic?

BigBlueHat commented 10 years ago

From "The Zen of Python, by Tim Peters" (aka import this)

0) Beautiful is better than ugly. 2) Simple is better than complex. 5) Sparse is better than dense. 6) Readability counts.

Possibly others. :grin:

garbados commented 10 years ago

The only tenet that sticks out to me about the CouchDB-Python API is "flat is better than nested", in that their Database object has a million methods while the Document object doesn't.

What about Cloudant-Python is ugly, complex, dense, and unreadable?

BigBlueHat commented 10 years ago

Wasn't meaning to imply that it was any of those things. Just that matching CouchDB-Python's API would be a Good Thing.

garbados commented 10 years ago

Ah, sorry for the misunderstanding.

+1 on minimizing the delta between the libraries.

garbados commented 10 years ago

One immediate item that comes to mind is in this line: https://github.com/cloudant-labs/cloudant-python/blob/master/cloudant/database.py#L34

db['doc_id'] returns a Document object, not a JSON, like CouchDB-Python. This means it doesn't throw an exception if the document is missing (because no HTTP request occurs), but matching the CouchDB-Python layout with this would be a one-line change: return self.document(name, **self.opts).get().result().json()

Do you think that would be an improvement?

BigBlueHat commented 10 years ago

Anything that prevents devs from rewriting stuff (or at least minimizes the delta as you said) will be a boon to adoption.

The more of that, the betta! :grin:

On Thu Nov 7 14:05:34 2013, Max wrote:

One immediate item that comes to mind is in this line: https://github.com/cloudant-labs/cloudant-python/blob/master/cloudant/database.py#L34

|db['doc_id']| returns a |Document| object, not a JSON, like CouchDB-Python. This means it doesn't throw an exception if the document is missing (because no HTTP request occurs), but matching the CouchDB-Python layout with this would be a one-line change: |return self.document(name, **self.opts).get().result().json()|

Do you think that would be an improvement?

— Reply to this email directly or view it on GitHub https://github.com/cloudant-labs/cloudant-python/issues/16#issuecomment-27995945.

davelab6 commented 10 years ago

Can this issue be closed? :)

garbados commented 10 years ago

Done :)