_id values with / are not handled correctly?
dholth opened this issue · comments
database['foo/bar'] = { 'baz':'quux'} always seems to give a conflict error. Perhaps couchdb-python is not %20-escaping these _id values?
No, it because document foo/bar
is already created. To update it you need specify his _rev
.
Maybe I'm misunderstanding what couchdb is supposed to be doing. The following command creates document baz
with an attachment named quux
. Then if I try to set db['/baz/splort']
it fails because baz
is already set.
>>> db['/baz/quux'] = {'testing':[1,2,3]}
>>> db['/baz']
<Document u'baz'@u'1-a3e2a2a4fd40b5f00f50a3a1f9bb3137'
{u'_attachments': {u'quux': {u'stub': True, u'length': 22, u'digest':
u'md5-7hE5LjA19+pF3J/DcBxEIw==', u'revpos': 1, u'content_type': u'application/json'}}}>
>>> In [38]: db['/baz/splort'] = {}
---------------------------------------------------------------------------
ResourceConflict Traceback (most recent call last)
...
site-packages/couchdb/http.pyc in request(self, method, url, body, headers, credentials, num_redirects)
424 raise ResourceNotFound(error)
425 elif status == 409:
426 raise ResourceConflict(error)
427 elif status == 412:
428 raise PreconditionFailed(error)
ResourceConflict: (u'conflict', u'Document update conflict.')
Can you please provide a complete REPL session/script that reproduces the failure you're seeing? Your snippet above doesn't appear to provide that.
There's the additional line showing the exception.
I cannot reproduce:
>>> db = couchdb.Server().create('test-ldsaofkdsofds')
>>> db['/baz/quux'] = {'testing':[1,2,3]}
>>> db['/baz']
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "couchdb/client.py", line 338, in __getitem__
_, _, data = _doc_resource(self.resource, id).get_json()
File "couchdb/http.py", line 555, in get_json
return self._request_json('GET', path, headers=headers, **params)
File "couchdb/http.py", line 578, in _request_json
headers=headers, **params)
File "couchdb/http.py", line 574, in _request
credentials=self.credentials)
File "couchdb/http.py", line 424, in request
raise ResourceNotFound(error)
couchdb.http.ResourceNotFound: (u'not_found', u'missing')
>>> db['/baz/splort'] = {}
>>>
Thanks. It looks like this is a consequence of my web server configuration, with CouchDB reverse proxied under a subdirectory.