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: object

Object manager attached to cls.objects by RDFModelMeta.

property backend
create(**kwargs)[source]
save(instance)[source]
Return type:

None

delete(instance)[source]
Return type:

None

bulk_create(instances)[source]

Persist many instances in one SPARQL update.

Mints IRIs for any instance whose iri is None. Issues a single INSERT DATA block; 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. Use bulk_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 with DELETE { <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 WHERE per IRI. Does not fire signals and does not strip inverse-property mirror triples (see #60).

get(iri)[source]
all()[source]
Return type:

RDFQuerySet

filter(*q_args, **kwargs)[source]
Return type:

RDFQuerySet

class djangordf.manager.RDFQuerySet(manager, q=None, order_by=(), limit=None, offset=None)[source]

Bases: object

Lazy queryset over an RDFManager.

Materialises on iteration / len / count / first / __getitem__(int) by issuing SELECT DISTINCT ?s to enumerate matching subjects, then calling manager.get(s) per subject. order_by and slicing are both chainable and lazy — they return new querysets carrying ORDER BY / LIMIT / OFFSET state that the SPARQL builder honours on next materialisation.

Parameters:
order_by(*fields)[source]
count()[source]
Return type:

int

first()[source]