djangordf.namespaces¶
The LangString dataclass plus the process-wide NamespaceRegistry
that resolves CURIEs to URIRef objects.
Namespace utilities for djangordf.
Holds the LangString dataclass (used by LangStringProperty)
and the process-wide NamespaceRegistry — a thin wrapper over
rdflib namespaces that gives users a single place to register prefix
bindings and a single resolve() that converts CURIEs into
URIRef objects.
- class djangordf.namespaces.LangString(value, lang)[source]¶
Bases:
objectA language-tagged literal, paired with a BCP 47 language tag.
Used by
LangStringPropertyto round-triprdf:langStringvalues cleanly between Python and the triple store.
- class djangordf.namespaces.NamespaceRegistry[source]¶
Bases:
objectPer-process registry of prefix -> namespace bindings.
Seeded with the common RDF/OWL/SKOS/Dublin Core/FOAF prefixes; extended through
register()(typically fromsettings.DJANGORDF_NAMESPACESviaapply_namespace_settings).- register(prefix, uri)[source]¶
Add or overwrite a prefix binding.
Raw strings are wrapped in
rdflib.Namespaceso concatenation producesURIRefobjects with no extra ceremony.
- djangordf.namespaces.apply_namespace_settings(extra=None)[source]¶
Feed
settings.DJANGORDF_NAMESPACES(or theextradict for tests) into the module-levelregistry.Safe to call before Django is configured: if settings access raises
ImproperlyConfiguredand no explicitextrawas given, this is a no-op.