File: base.py

package info (click to toggle)
python-couchdbkit 0.6.5-1
  • links: PTS, VCS
  • area: main
  • in suites: jessie, jessie-kfreebsd
  • size: 640 kB
  • ctags: 1,257
  • sloc: python: 7,240; makefile: 2
file content (33 lines) | stat: -rw-r--r-- 860 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
# -*- coding: utf-8 -
#
# This file is part of couchdbkit released under the MIT license. 
# See the NOTICE for more information.

def check_callable(cb):
    if not callable(cb):
        raise TypeError("callback isn't a callable")

class ConsumerBase(object):

    def __init__(self, db, **kwargs):
        self.db = db

    def fetch(self, cb=None, **params):
        resp = self.db.res.get("_changes", **params)
        if cb is not None:
            check_callable(cb)
            cb(resp.json_body)
        else:
            return resp.json_body

    def wait_once(self, cb=None, **params):
        raise NotImplementedError

    def wait(self, cb, **params):
        raise NotImplementedError
    
    def wait_once_async(self, cb, **params):
        raise NotImplementedError

    def wait_async(self, cb, **params):
        raise NotImplementedError