This library is for programs that use twisted for networking, use rdflib for RDF, and want to do sparql over http. It contains a client and a server, but you should be able to mix and match with other sparql clients and servers.
| Classes |
|---|
| RemoteGraph twisted web client that talks to SPARQLResource (or other sparql-over-http servers) |
| ⇑ HTTP ⇓ |
| SPARQLResource twisted web resource that supports various GET/POST commands |
| Graph2 slightly different API for the rdflib graph class |
| ConjunctiveGraph (from rdflib) |
There is also a LocalGraph class, which presents exactly the same API as RemoteGraph, but it talks to an in-process rdflib graph. This is convenient for testing your async RemoteGraph code without bothering to setup the http connection.
# this code will work whether graph is a RemoteGraph or a LocalGraph
def method(self):
d = graph.remoteLabel(subj)
d.addCallback(self.withLabel)
def withLabel(self, label):
print label
./db/
bin/sparqlserve --home db
2007/01/22 00:58 -0700 [-] Log opened. 2007/01/22 00:58 -0700 [-] twisted.web.server.Site starting on 9991 2007/01/22 00:58 -0700 [-] Starting factory <twisted.web.server.Site instance at 0xb7646aac>
bin/graphimport hello.ntServer says:
2007/01/22 01:14 -0700 [HTTPChannel,0,127.0.0.1] 127.0.0.1 - - [22/Jan/2007:08:14:08 +0000] "POST /add?context=http%3A//example.org/%23context HTTP/1.0" 200 2 "-" "Twisted PageGetter"
bin/dumpgraphServer says:
2007/01/22 01:15 -0700 [HTTPChannel,1,127.0.0.1] 127.0.0.1 - - [22/Jan/2007:08:15:32 +0000] "GET /?query=SELECT%20%3Fs%20%3Fp%20%3Fo%20WHERE%20%7B%20%3Fs%20%3Fp%20%3Fo%20%7D HTTP/1.0" 200 617 "-" "Twisted PageGetter"Client says:
[(u'http://example.org/hello',
u'http://example.org/to',
rdflib.Literal('world',language=None,datatype=None)),
(u'http://example.org/hello',
u'http://www.w3.org/2000/01/rdf-schema#label',
rdflib.Literal('Hello',language=None,datatype=None))]
bin/query "SELECT ?label WHERE { ?s <http://www.w3.org/2000/01/rdf-schema#label> ?label }"
[{'label': rdflib.Literal('Hello',language=None,datatype=None)}]
I deliberately made an error request to cause the the traceback below. The table at the bottom is really nice for large programs, since it shows what lines in your code made the various queries.
cd test trial test_dictquery.py test_remotegraph.py # these mostly work (they all work with a hacked rdflib) trial test_syncimport.py # this one might not do as well (not sure why- it works in my kit)