def __getattr__(self, name): # if attr is not found and starts with an upper case letter, it might be the name # of one of the registered classes. In that case, return a function that would instantiate # such an object in this graph if name[0].isupper() and name in ontology.class_names(): def inst(basenode = None, **kwargs): result = super(VersionedMediaGraph, self).__getattr__(name)(basenode, **kwargs) if isinstance(result, Media): result.lastModified = time.time() return result return inst raise AttributeError, name
def __getattr__(self, name): # if attr is not found and starts with an upper case letter, it might be the name # of one of the registered classes. In that case, return a function that would instantiate # such an object in this graph if name[0].isupper() and name in ontology.class_names(): def inst(basenode = None, **kwargs): # if we're copying a node from a different graph, we need to intercept it here to # add it correctly with its dependencies instead of creating from scratch if basenode is not None and basenode.node.graph() != self: return self.add_object(basenode) return ontology.get_class(name)(basenode = basenode, graph = self, **kwargs) return inst raise AttributeError, name
def __getattr__(self, name): # if attr is not found and starts with an upper case letter, it might be the name # of one of the registered classes. In that case, return a function that would instantiate # such an object in this graph if name[0].isupper() and name in ontology.class_names(): def inst(basenode=None, **kwargs): # if we're copying a node from a different graph, we need to intercept it here to # add it correctly with its dependencies instead of creating from scratch if basenode is not None and basenode.node.graph() != self: return self.add_object(basenode) return ontology.get_class(name)(basenode=basenode, graph=self, **kwargs) return inst raise AttributeError, name