def convert_ids2objects(self): """ Convert object IDs from `self._params` to objects if needed. Only IDs tbat belong to relationship field of `self._model_class` are converted. """ from nefertari.engine import is_relationship_field, relationship_cls for field in self._params.keys(): if not is_relationship_field(field, self._model_class): continue model_cls = relationship_cls(field, self._model_class) self.id2obj(field, model_cls)
def convert_ids2objects(self): """ Convert object IDs from `self._json_params` to objects if needed. Only IDs that belong to relationship field of `self.Model` are converted. """ if not self.Model: log.info("%s has no model defined" % self.__class__.__name__) return for field in self._json_params.keys(): if not engine.is_relationship_field(field, self.Model): continue rel_model_cls = engine.get_relationship_cls(field, self.Model) self.id2obj(field, rel_model_cls)
def convert_ids2objects(cls, obj_dict, model): """ Convert object IDs from a dictionary to objects if needed. Only IDs that belong to relationship field of `model` are converted. """ if not model: log.info("%s has no model defined" % cls.__name__) return for field in obj_dict: if not engine.is_relationship_field(field, model): continue rel_model_cls = engine.get_relationship_cls(field, model) BaseView.id2obj(obj_dict, field, rel_model_cls)