def add_object_with_intent(self, intent, name): obj = FObject(name=name, group=self.group) obj.save() if len(intent) != 0: get_attr = lambda name: self.group.content_objects(FAttribute).get( pk=name) obj.attributes.add(*[get_attr(pk) for pk in intent])
def set_context(group, cxt): """Set current context to context from fca.context""" clear_db(group) for attribute_name in cxt.attributes: attr = FAttribute(name=attribute_name, group=group) attr.save() for object_name in cxt.objects: obj = FObject(name=object_name, group=group) obj.save() object_intent = cxt.get_object_intent(object_name) get_attr = lambda name: group.content_objects(FAttribute).get(name=name) obj.attributes.add(*[get_attr(name) for name in object_intent])
def set_context(group, cxt): """Set current context to context from fca.context""" clear_db(group) for attribute_name in cxt.attributes: attr = FAttribute(name=attribute_name, group=group) attr.save() for object_name in cxt.objects: obj = FObject(name=object_name, group=group) obj.save() object_intent = cxt.get_object_intent(object_name) get_attr = lambda name: group.content_objects(FAttribute).get(name=name ) obj.attributes.add(*[get_attr(name) for name in object_intent])
def add_attribute_with_extent(self, extent, name): attr = FObject(name=name, group=self.group) attr.save() if len(extent) != 0: get_obj = lambda name: self.group.content_objects(FObject).get(pk=name) attr.fobject_set.add(*[get_obj(pk) for pk in extent])
def add_object_with_intent(self, intent, name): obj = FObject(name=name, group=self.group) obj.save() if len(intent) != 0: get_attr = lambda name: self.group.content_objects(FAttribute).get(pk=name) obj.attributes.add(*[get_attr(pk) for pk in intent])