def _remove(self): _request = json.loads(self.request.body) _script_uuid = _request.get("script_uuid") if _script_uuid == None or len(_script_uuid) == 0: self.setErrorCode(API_ERR.NO_PARA) return _row = PredefinedScript(uuid=_script_uuid) _row.async_delete(self.application.redis) _row.delete_redis_keys(self.application.redis) return
def _add(self): _request = json.loads(self.request.body) _app_uuid = _request.get("app_uuid") _group_uuid = _request.get("group_uuid") _script_answer = _request.get("script_answer") _script_question = _request.get("script_question") if _script_answer == None or len(_script_answer) == 0: self.setErrorCode(API_ERR.NO_PARA) return _uuid = str(uuid.uuid1()) _row = PredefinedScript(uuid=_uuid, app_uuid=_app_uuid, group_uuid=_group_uuid, script_question=_script_question, script_answer=_script_answer) _row.async_add() _row.create_redis_keys(self.application.redis) _ret = self.getReturnData() _ret = copy.deepcopy(_request) _ret["uuid"] = _uuid return
def _move(self): _request = json.loads(self.request.body) _group_uuid = str(_request.get("group_uuid")) _script_uuid = _request.get("script_uuid") if _script_uuid == None or len(_script_uuid) == 0: self.setErrorCode(API_ERR.NO_PARA) return _script = redis_hash_to_dict(self.application.redis, PredefinedScript, _script_uuid) if _script == None: logging.error("No such script: %s" % _script_uuid) return _old_group_uuid = str(_script.get("group_uuid")) _key = PredefinedScript.__tablename__ + ".group_uuid." + _old_group_uuid self.application.redis.srem(_key, _script_uuid) _row = PredefinedScript(uuid=_script_uuid, group_uuid=_group_uuid) _row.async_update() _row.update_redis_keys(self.application.redis) return