def _notify_clients(self, data): """Get all the ``client_id``s that are live against a repo and push the new / changed / deleted data to them. """ redis = Redis(namespace=self.repository.id, expire_after=300) redis_ready_data = utils.json_encode(data) for key in redis('keys', 'client-*'): client_id = key.split('client-')[1] redis('rpush', client_id, data)
def _listen(self): """Register the ``client_id`` against the repo in redis, so it's renewed every poll and expires after a few minutes. Listen for updates against it. """ client_id = self.get_argument('client_id', u'') try: client_id = schema.ClientId(not_empty=True).to_python(client_id) except formencode.Invalid, err: data = utils.json_encode({'_id': 'Invalid ``client_id``'}) return self.error(400, body=data)
def _fetch(self): """Gets the thing by ``_id`` and ensures that any reused sections are uptodate. """ if self.settings['debug']: s = time.time() _id = self.get_argument('_id', u'') try: _id = schema.CouchDocumentId(not_empty=True).to_python(_id) except formencode.Invalid, err: data = utils.json_encode({'_id': 'Invalid ``_id``'}) return self.error(400, body=data)