def delete(self, uri): globalGraph = ConjunctiveGraph(self.store) globalGraph.remove((uri,None,None)) g = Graph(self.store, uri) g.remove((None,None,None)) g.commit() return Graph()
def delete(self,uri): idb = Graph(self.store,uri) if len(idb) == 0: abort(404, "Resource does not exist or is not deletable.") idb.remove((None,None,None)) g = ConjunctiveGraph(self.store) g.remove((uri,None,None)) g.remove((None,None,uri))
def create(self, graph): uri = self.create_uri() inputUri = "#" g = Graph(self.store,URIRef(uri)) g.remove((None,None,None)) g += rebase(graph, uri, inputUri) g.add((URIRef(uri),RDF.type,self.cl)) g.add((URIRef(uri), dc.created, Literal(datetime.datetime.now()))) g.commit() o = Graph() o.add((URIRef(inputUri),OWL.sameAs,uri)) return o
def _prep_graph(resource, about=None): #print '_prep_graph', resource.identifier, about content_type = resource.value(app.NS.ov.hasContentType) if content_type is not None: content_type = content_type.value #print 'graph content type', resource.identifier, content_type #print resource.graph.serialize(format="nquads") g = Graph(store=resource.graph.store, identifier=resource.identifier) text = resource.value(app.NS.prov.value) if content_type is not None and text is not None: #print 'Content type:', content_type, resource.identifier html = None if content_type in ["text/html", "application/xhtml+xml"]: html = Literal(text.value, datatype=NS.RDF.HTML) if content_type == 'text/markdown': #print "Aha, markdown!" #print text.value html = markdown.markdown(text.value) attributes = [ 'vocab="%s"' % app.NS.local, 'base="%s"' % app.NS.local, 'prefix="%s"' % ' '.join([ '%s: %s' % x for x in list(app.NS.prefixes.items()) ]) ] if about is not None: attributes.append('resource="%s"' % about) html = '<div %s>%s</div>' % (' '.join(attributes), html) html = Literal(html, datatype=NS.RDF.HTML) text = html content_type = "text/html" #print resource.identifier, content_type if html is not None: resource.set(app.NS.sioc.content, html) try: g.remove((None, None, None)) g.parse(data=text, format='rdfa', publicID=app.NS.local) except: pass else: #print "Deserializing", g.identifier, 'as', content_type #print dataFormats if content_type in dataFormats: g.parse(data=text, format=dataFormats[content_type], publicID=app.NS.local)