def append(self, name, value, reverse_name = None, validate = True): if multi_is_instance(value, AbstractNode): if reverse_name is None: reverse_name = is_of(name) self.add_link(name, value, reverse_name) else: raise TypeError("Trying to append to property '%s' of %s: '%s', but it is not of a supported type (literal or object node): %s" % (name, self, value, type(value).__name__)) # update the cache of valid classes if validate: self.update_valid_classes()
def append(self, name, value, reverse_name=None, validate=True): if multi_is_instance(value, AbstractNode): if reverse_name is None: reverse_name = is_of(name) self.add_link(name, value, reverse_name) else: raise TypeError( "Trying to append to property '%s' of %s: '%s', but it is not of a supported type (literal or object node): %s" % (name, self, value, type(value).__name__)) # update the cache of valid classes if validate: self.update_valid_classes()
def set(self, name, value, reverse_name = None, validate = True): """Sets the property name to the given value. If value is an ObjectNode, we're actually setting a link between them two, so we use reverseName as the name of the link when followed in the other direction. If reverseName is not given, a default of 'isNameOf' (using the given name) will be used.""" if isinstance(value, (BaseObject, AbstractNode, list, set, collections.Iterator)): if reverse_name is None: reverse_name = is_of(name) self.set_link(name, value, reverse_name) elif is_literal(value): self.set_literal(name, value) else: raise TypeError("Trying to set property '%s' of %s to '%s', but it is not of a supported type (literal or object node): %s" % (name, self, value, type(value).__name__)) # update the cache of valid classes if validate: self.update_valid_classes()
def set(self, name, value, reverse_name=None, validate=True): """Sets the property name to the given value. If value is an ObjectNode, we're actually setting a link between them two, so we use reverseName as the name of the link when followed in the other direction. If reverseName is not given, a default of 'isNameOf' (using the given name) will be used.""" if isinstance( value, (BaseObject, AbstractNode, list, set, collections.Iterator)): if reverse_name is None: reverse_name = is_of(name) self.set_link(name, value, reverse_name) elif is_literal(value): self.set_literal(name, value) else: raise TypeError( "Trying to set property '%s' of %s to '%s', but it is not of a supported type (literal or object node): %s" % (name, self, value, type(value).__name__)) # update the cache of valid classes if validate: self.update_valid_classes()