Skip to content

Document Update Handler (update_doc) support for PUT and POST #230

Open
@djc

Description

@djc

From te...@prosauce.org on October 03, 2013 01:23:33

couchdb/client.py:
def update_doc(self, name, docid=None, **options):
"""Calls server side update handler.

    :param name: the name of the update handler function in the format
                 ``designdoc/updatename``.
    :param docid: optional ID of a document to pass to the update handler.
    :param options: optional query string parameters.
    :return: (headers, body) tuple, where headers is a dict of headers
             returned from the list function and body is a readable
             file-like instance
    """
    path = _path_from_name(name, '_update')
    if docid is None:
        func = self.resource(*path).post
    else:
        path.append(docid)
        func = self.resource(*path).put
    _, headers, body = func(**options)
    return headers, body

The Document Update Handlers API reference ( http://docs.couchdb.org/en/latest/ddocs.html#update-functions ) mentions support for both PUT and POST. For larger updates (>650bytes) PUT is not appropriate (HTTP 414, request too long, concerns). The module should prefer POST or include a kwarg to allow the caller to decide the verb.

Thanks!

Original issue: http://code.google.com/p/couchdb-python/issues/detail?id=230

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions