def _wrap_commit(self, request, response, iids=None, **options): for id, iid in zip(response, iids): id, flag, info = id if int(flag): yield instance_session_result(iid, True, id, False, float(info)) else: msg = info.decode(request.encoding) yield CommitException(msg)
def _wrap_commit(self, response, iids=None, redis_client=None, **options): for id, iid in zip(response, iids): id, flag, info = id if int(flag): yield instance_session_result(iid, True, id, False, float(info)) else: msg = info.decode(redis_client.encoding) yield CommitException(msg)
def callback(self, request, response, args, meta=None, backend=None, script=None, **options): if script == 'delete': res = (instance_session_result(r,False,r,True,0) for r in response) return session_result(meta, res) elif script == 'commit': res = self._wrap_commit(request, response, **options) return session_result(meta, res) elif script == 'load': return self.load_query(request, response, backend, meta, **options) else: return response
def callback(self, response, meta=None, backend=None, odm_command=None, **opts): if odm_command == 'delete': res = (instance_session_result(r, False, r, True, 0) for r in response) return session_result(meta, res) elif odm_command == 'commit': res = self._wrap_commit(response, **opts) return session_result(meta, res) elif odm_command == 'load': return self.load_query(response, backend, meta, **opts) elif odm_command == 'structure': return self.flush_structure(response, backend, meta, **opts) else: return response
def flush_structure(self, sm, pipe): processed = False for instance in chain(sm._delete_query, sm.dirty): processed = True state = instance.state() binstance = instance.backend_structure(pipe) n = len(pipe.command_stack) binstance.commit() script_dependency = [] for c in pipe.command_stack[n:]: script_name = c.options.get('script_name') if script_name: script_dependency.append(script_name) pipe.exists(binstance.id, script_dependency=script_dependency) pipe.add_callback(lambda p,result:\ instance_session_result(state.iid, result, instance.id, state.deleted, 0)) if processed: pipe.add_callback( partial(structure_session_callback,sm))
def process_delete(self, meta, ids, result): if result['err']: yield Exception(result) else: for id in ids: yield instance_session_result(id, True, id, True, 0)
def process_result(self, result, iids): for id, iid in zip(result, iids): yield instance_session_result(iid, True, id, False, 0)