def DELETE(self):
input_data = web.data()
data = urlparse.parse_qs(input_data)
v_ct_fids = db.query("select distinct t.source_fid,t.target_fid,t.type_fid,t.owner,t.family_id from t_ci_relation t where t.family_id=$fid and t.endtime=$endtime",vars={'endtime':ENDTIME,'fid':data['fid'][0]})
json_en = demjson.encode(v_ct_fids)
json_de = demjson.decode(json_en)
v_ct_fid_num = len(json_de)
if v_ct_fid_num == 0:
return 2 #there is no records to delete in table T_CI_RELATION
elif v_ct_fid_num > 1:
return 3 #there are more than one records to delete in table T_CI_RELATION
v_curtime = time.strftime("%Y%m%d%H%M%S", time.localtime())
#Notice?if the relation is composition and the target ci exists, we should delete the relative ci
v_target_fids = db.query("select t.family_id, crt.relation from t_ci t, t_ci_relation_type crt where t.family_id=$target_fid and t.endtime=$endtime and crt.family_id=$type_fid and crt.endtime=$endtime and crt.relation='COMPOSITION'",vars={'endtime':ENDTIME,'target_fid':json_de[0]['TARGET_FID'],'type_fid':json_de[0]['TYPE_FID']})
target_json_en = demjson.encode(v_target_fids)
target_json_de = demjson.decode(target_json_en)
v_target_num = len(target_json_de)
if v_target_num <> 0:
#delete the existed ci. It will also delete the relative ci_attribute and ci_relation.
n = webci.fn_delete_ci(json_de[0]['TARGET_FID'], v_curtime, data['change_log'][0])
else:
#delete t_ci_relation
n = fn_delete_cirela(data['fid'][0],v_curtime,data['change_log'][0])
return n
评论列表
文章目录