--- a/cubicweb/rdf.py Fri Feb 14 18:15:55 2020 +0100
+++ b/cubicweb/rdf.py Fri Feb 28 17:11:01 2020 +0100
@@ -15,7 +15,8 @@
# You should have received a copy of the GNU Lesser General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
-from rdflib import Namespace, ConjunctiveGraph, plugin
+from rdflib import ConjunctiveGraph, plugin
+from rdflib.namespace import Namespace, RDF, FOAF
import rdflib_jsonld # noqa
plugin.register("jsonld", plugin.Serializer, "rdflib_jsonld.serializer", "JsonLDSerializer")
@@ -30,16 +31,16 @@
'application/ld+json': 'json-ld',
}
-namespaces = {
- "rdf": "http://www.w3.org/1999/02/22-rdf-syntax-ns#",
- "schema": "http://schema.org/",
+NAMESPACES = {
+ "rdf": RDF,
+ "schema": Namespace("http://schema.org/"),
+ "foaf": FOAF,
}
-NS_VARS = {ns: Namespace(uri) for ns, uri in namespaces.items()}
-
# dict: name of CWEType -> list of regid of adapters derived from EntityRDFAdapter
ETYPES_ADAPTERS = {
+ "CWUser": ("rdf.foaf",),
}
@@ -47,8 +48,8 @@
"""factory to build a ``ConjunctiveGraph`` and bind all namespaces
"""
graph = ConjunctiveGraph()
- for vocab, rdfns in NS_VARS.items():
- graph.bind(vocab, rdfns)
+ for prefix, rdfns in NAMESPACES.items():
+ graph.bind(prefix, rdfns)
return graph