gjhiggins/rdflib — Issue #180: Clarify confusion around type of context element in ConjunctiveGraphs  and context aware stores
Author: gjhiggins
Created: 2011-10-19 01:36:17+00:00
State: open

Originally filed by gromgull on 2011-08-20T07:58:07

In the conjunctivegraph, the context field is assumed to be a graph with the identifier set to the URI of the context, i.e. this is what happens if you create context like this:

{{{
g=ConjunctiveGraph()
uri1=URIRef("http://example.org/mygraph1")
uri2=URIRef("http://example.org/mygraph2")

bob = URIRef(u'urn:bob')
likes = URIRef(u'urn:likes')
pizza = URIRef(u'urn:pizza')

g.get_context(uri1).add((bob, likes, pizza))
g.get_context(uri2).add((bob, likes, pizza))
}}}

Now g.contexts() returns a generator over some graphs.

Now, for code working on the store level, i.e. serializers and parsers, there should perhaps not be any graph objects?

I came across this when looking at the nquad parser, here:

http://code.google.com/p/rdflib/source/browse/rdflib/plugins/parsers/nquads.py?spec=svn436d7ac34aee1d42f5ce55f2583d61de7dff9033&name=nquads&r=436d7ac34aee1d42f5ce55f2583d61de7dff9033#142

This adds context as simply an URI ref.

I added a "work-around" to make the conjunctivegraph.contexts generator work "correctly" here:

http://code.google.com/p/rdflib/source/browse/rdflib/graph.py?spec=svnafdf0e4fb39e73a3c37a939a6d1d83f90bf7a418&name=nquads&r=afdf0e4fb39e73a3c37a939a6d1d83f90bf7a418#945

Is this ok?