Build an external handler
Building an external handler with couchdbkit is easy. The only thing you have to do is to create an object inheriting from `couchdbkit.external` module.
Here is a little snippet that shows you how to handle the example external process from CouchDB wiki with couchdbkit.
from couchdbkit.external import External
import anyjson
class Test(External):
def handle_line(self, line):
self.send_response(200,
“got message external object %s” % anyjson.serialize(line),
{“Content-type”: “text/plain”})
if name == “main“:
Test().run()
All lines received by the external handler are handled in `handle_line` method of External instance. Then the `send_response` method can be used to send the response. It takes the http status code, body and headers as arguments. `This method is a wrapper around `write` method of your instance.
`couchdbkit.External` interface has been used to build the wsgi external handler. Its code is also a good example of use.