Listen to changes in CouchDatabase

# [SNIPPET_NAME: Listen to changes in CouchDatabase]
# [SNIPPET_DESCRIPTION: Register a callback that will listen to changes in the CouchDatabase]
# [SNIPPET_AUTHOR: Manuel de la Pena <[email protected]>]
import time
from desktopcouch.records.server import CouchDatabase

# we are going to be listening to the changes in this callback
def changes_cb(seq=None, id=None, changes=None):
    print seq
    print id
    print changes
db = CouchDatabase("listenchangesexample", create=True)

# is better, use glib main loop or twisted task!
while True:

# got to /home/$USER/.local/share/desktop-couch/couchdb.html and make
# changes to the listenchangesexample to see the callback output