djangordf.manager¶
The RDFManager attached to every RDFModel subclass as objects,
and the lazy RDFQuerySet returned by all() and filter().
Default object manager bound to each RDFModel subclass.
RDFManager provides the Django-style Model.objects entry point:
create, get, save, delete, all and filter. Reads
hydrate instances by dispatching the CONSTRUCTed graph through each
property’s from_rdf. all and filter return a lazy
RDFQuerySet that only hits the store on iteration or terminal
methods (len, count, first).
- class djangordf.manager.RDFManager(model_class)[source]¶
Bases:
objectObject manager attached to
cls.objectsbyRDFModelMeta.- property backend¶
- bulk_create(instances)[source]¶
Persist many instances in one SPARQL update.
Mints IRIs for any instance whose
iriisNone. Issues a singleINSERT DATAblock; does not fire signals and does not emit inverse-property mirror triples (see #60). Intended for new objects only — re-running it on existing IRIs would add duplicate triples. Usebulk_update()when persisting changes to existing instances.
- bulk_update(instances)[source]¶
Re-persist many existing instances in one SPARQL update.
Each instance must already carry an
iri. Issues one multi-statement update withDELETE { <iri> ?p ?o } WHERE { <iri> ?p ?o } ; INSERT DATA { ... }per instance. Does not fire signals and does not emit inverse-property mirror triples (see #60).
- bulk_delete(instances)[source]¶
Strip many instances in one SPARQL update.
Issues one multi-statement update with one
DELETE WHEREper IRI. Does not fire signals and does not strip inverse-property mirror triples (see #60).
- class djangordf.manager.RDFQuerySet(manager, q=None, order_by=(), limit=None, offset=None)[source]¶
Bases:
objectLazy queryset over an
RDFManager.Materialises on iteration /
len/count/first/__getitem__(int)by issuingSELECT DISTINCT ?sto enumerate matching subjects, then callingmanager.get(s)per subject.order_byand slicing are both chainable and lazy — they return new querysets carryingORDER BY/LIMIT/OFFSETstate that the SPARQL builder honours on next materialisation.- Parameters:
manager (RDFManager)
order_by (tuple)