nicolaisi / couchquery Goto Github PK
View Code? Open in Web Editor NEWPython library for simple and dynamic access to CouchDB
Python library for simple and dynamic access to CouchDB
When setting a user/password in the uri (couchquery.createdb('http://admin:foobar@couchdb/callstats'), couchquery does not transmit user/password info to CouchDB
Currently it is possible to get views from a map inside the source tree, it would be very nice to have the possibility to add filters also to design documents.
So with a map called "filters" and then the name and next a filter.js where the actual filter is stored.
asynchttp is supplied but not used.
But you can use eventlet/gevent monkey-patching and don't bother with sockets at all.
the following line of code:
resp = couchquery.createdb('http://nick:banana@localhost:5984/test_couchquery')
...results in the following request:
PUT http://localhost:5984/test_couchquery/
Somewhere along the way, the "credentials" get lost, and are never sent to CouchDB.
I'm using svn and sync_design_doc chokes on the .svn directories. More specifically, it creates a view with an empty name and no map or reduce functions. This results in a corrupted design doc.
I'd like to propose the following patch in couchquery/init.py starting at line 518:
for view in os.listdir(directory): if view.startswith('.'): continue v = {}
There's a "bug" when using NGINX in front of CouchDB, and PUTs. NGINX requires a Content-Length, to accept the request. On other couchDB modules, an option to add an extra header has been added to correct this problem (which is not on couchquery's side, but more on NGINX's strictness).
See http://code.google.com/p/couchdb-python/issues/detail?id=130 or http://groups.google.com/group/couchrest/browse_thread/thread/ed0e251936b391ac for details of headers
sync_design_doc works OK in my code when working in admin party. However an exception is generated when nog in admin party mode.
https://travis-ci.org/nicolaisi/couchquery/jobs/13254230
The test already pass before passing to Travis CI and it passed the next build. This is a test during deletedb and the connection to cloudant is lost.
This seems like unstable connection.
createdb() includes the following:
assert response.status == 201
...which causes an exception without returning the response body, which in my case was:
str: {"error":"unauthorized","reason":"You are not a server admin."}
If the create db fails, you should still return the reponse, so the caller gets the "reason".
The class Httplib2Client uses 'http://' directly, this cases https not to work (e.g. with Cloudant).
Locally I've monkeypatched it to use a variable called protocol, i.e. s/'http://'/protocol/g with:
if '@' in self.uri:
protocol = 'https://' if 'https' in self.uri else 'http://'
What are they for?
https://travis-ci.org/nicolaisi/couchquery/jobs/17121555
Since I added an extra test case that connects to a server (initially wanted to test SSH connection), it has been passing from my local environment, but when I push to Travis, it fails and returning a Http 404 response.
This means, it is not detecting the view that the had been previously created.
(and possibly other relevant places)
>>> db = couchquery.Database(...)
>>> db.get('/bar')
...
... CouchDBDocumentDoesNotExist: No document at id /bar
But a /bar does exist. It should be sending a request with "%2Fbar" but the method fails to correctly quote its argument.
Please, take a look
http://jcalderone.livejournal.com/39794.html
sync_design_doc() does not use credentials
db = cq.Database('http://nick:banana@localhost:5984/test_couchquery') resp = db.create({'name':'Nick','age':42}) if resp.get('ok'): print 'saved doc' # <------ this works db.sync_design_doc('banzai', views_dir) # <----- this does not
I can save a doc, but can not sync_design_doc:
couchquery.CouchDBException: {"error":"unauthorized","reason":"You are not a db or server admin."}
This is a test ...
Currently there is no "compact" method. Also the command
result = db.http.post(self.dbConnection.uri + '_compact')
yields a faulty result
a version bump script will be handy.
@mikeal, I'll work on a few more bug fixes and maybe we can plan for next release? What do you think.
couchquery does not work for https URLs.
When a normal update is done a response of 201 is given. However with Couchdb NOT in admin party when one tries to update the _security document it a response of 200 is generated when it is succesful. So everything works perfectly, but couchquery only accepts a 201 hence an exception is generated.
in the init.py the version is not updated to 0.10.1
documentation on compaction and filters need to be created.
The variable at couch_httpd_auth
-> require_valid_user
determines whether the database is protected against password or not. By setting this to true
, the tests will all fail as it requires credentials.
Adding credentials to the URI will pass the tests, but when I deactivate this variable to false
, the test will fail again.
Need some kind of falllback measurement here.
I use the changes module that you have added. This works OK if couchdb is in admin party mode. However, when I switch off the admin party mode, I get an error.
c =httplib.HTTPConnection(u.netloc)
t = c.request('GET',u.path)
Traceback (most recent call last):
File "", line 1, in
File "/usr/lib/python2.7/httplib.py", line 973, in request
self._send_request(method, url, body, headers)
File "/usr/lib/python2.7/httplib.py", line 1007, in _send_request
self.endheaders(body)
File "/usr/lib/python2.7/httplib.py", line 969, in endheaders
self._send_output(message_body)
File "/usr/lib/python2.7/httplib.py", line 829, in _send_output
self.send(msg)
File "/usr/lib/python2.7/httplib.py", line 791, in send
self.connect()
File "/usr/lib/python2.7/httplib.py", line 772, in connect
self.timeout, self.source_address)
File "/usr/lib/python2.7/socket.py", line 553, in create_connection
for res in getaddrinfo(host, port, 0, SOCK_STREAM):
socket.gaierror: [Errno -2] Name or service not known
I have tried the exact statements from the python console and I get this error (which is the error that is produced by the script) So obviously something is going wrong there, but I have no idea what is going on. Could you take a look?
Currently views supported are written in JS. which is default for CouchDB. It might be a good feature to have view also written in python.
tests/test_document.py:43:
self = <couchquery.Views object at 0x28a8b90>, name = 'banzai'
def __getattr__(self, name):
if debugging:
response = self.db.http.head(self.path+name+'/')
if not debugging or response.status == 200:
setattr(self, name, Design(self.db, '_design/'+name))
return getattr(self, name)
else:
raise AttributeError("No view named "+name)
E AttributeError: No view named banzai
Plan to update document next.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.