def onMessage(self, payload, isbinary): close_old_connections() payload = payload.decode('utf-8') data = json.loads(payload) project = data.get('project', data.get('_meta', {}).get('project')) storage = create_project_storage(project, author=self.user) projects = storage.__class__.get_projects(self.user) if project and str(project) not in projects: self.sendMessage({'status': 4004, 'message': 'Project not found'}) return deferred = defer.maybeDeferred( wrap_callback, None, self._on_message, storage=storage, data=data) deferred.addCallbacks(self.sendMessage, partial(self.send_error, data))
def storage(self): if 'project_id' in self.kwargs: return create_project_storage(self.kwargs['project_id'], author=self.user) return None
def storage(self): if 'project_id' in self.kwargs: return create_project_storage( self.kwargs['project_id'], author=self.user) return None