def getAllPkByFk(self,fk): '''根据外键获取主键列表 ''' name = '%s_fk:%s'%(self._name,fk) fkmm = MFKMode(name) pklist = fkmm.get('pklist') if pklist is not None: return pklist props = {self._fk:fk} dbkeylist = util.getAllPkByFkInDB(self._name, self._pk, props) name = '%s_fk:%s'%(self._name,fk) fkmm = MFKMode(name, pklist = dbkeylist) fkmm.insert() return dbkeylist
def getAllPkByFk(self, fk): """根据外键获取主键列表 """ name = '%s_fk:%s' % (self._name, fk) fkmm = MFKMode(name) pklist = fkmm.get('pklist') if pklist is not None: return pklist props = {self._fk: fk} dbkeylist = util.getAllPkByFkInDB(self._name, self._pk, props) name = '%s_fk:%s' % (self._name, fk) fkmm = MFKMode(name, pklist=dbkeylist) fkmm.insert() return dbkeylist
def getAllPkByFk(self, fk): '''根据外键获取主键列表 ''' name = '%s_fk:%s' % (self._name, fk) fkmm = MFKMode(name) pklist = fkmm.get('pklist') if pklist is not None: # 区别第一次加载 return list(set(pklist)) props = {self._fk: fk} dbkeylist = util.getAllPkByFkInDB(self._name, self._pk, props) name = '%s_fk:%s' % (self._name, fk) fkmm = MFKMode(name, pklist=dbkeylist) fkmm.insert() return list(set(dbkeylist))
def _update_fk(self,pk,old_fk_value,fk_value): """ """ tb_name = self._name.split(":")[0] old_name = '%s_fk:%s'%(tb_name,old_fk_value) old_fkmm = MFKMode(old_name) old_pklist = old_fkmm.get('pklist') if old_pklist is None:#如果外键列表没有生成,则重新生成 props = {self._fk:old_fk_value} old_pklist = util.getAllPkByFkInDB(tb_name, self._pk, props) if old_pklist and pk in old_pklist:#清理原有的外键 old_pklist.remove(pk) old_fkmm.update('pklist', old_pklist) if fk_value is None: return new_name = '%s_fk:%s'%(tb_name,fk_value) new_fkmm = MFKMode(new_name) new_pklist = new_fkmm.get('pklist') if new_pklist is None: props = {self._fk:fk_value} new_pklist=util.getAllPkByFkInDB(tb_name,self._pk, props) if pk not in new_pklist: new_pklist.append(pk) new_fkmm.update('pklist', new_pklist)
def _update_fk(self, pk, old_fk_value, fk_value): """ """ tb_name = self._name.split(":")[0] old_name = '%s_fk:%s' % (tb_name, old_fk_value) old_fkmm = MFKMode(old_name) old_pklist = old_fkmm.get('pklist') if old_pklist is None: #如果外键列表没有生成,则重新生成 props = {self._fk: old_fk_value} old_pklist = util.getAllPkByFkInDB(tb_name, self._pk, props) if old_pklist and pk in old_pklist: #清理原有的外键 old_pklist.remove(pk) old_fkmm.update('pklist', old_pklist) if fk_value is None: return new_name = '%s_fk:%s' % (tb_name, fk_value) new_fkmm = MFKMode(new_name) new_pklist = new_fkmm.get('pklist') if new_pklist is None: props = {self._fk: fk_value} new_pklist = util.getAllPkByFkInDB(tb_name, self._pk, props) if pk not in new_pklist: new_pklist.append(pk) new_fkmm.update('pklist', new_pklist)
def getAllPkByFk(self,**kw): """ """ dbkeylist = util.getAllPkByFkInDB(self._name, self._pk, kw) return dbkeylist