oldman.rest package¶
Submodules¶
oldman.rest.controller module¶
- class oldman.rest.controller.HTTPController(manager, config={})[source]¶
Bases: object
HTTP.
TODO: check declared methods (only GET and HEAD are implicit).
- DEFAULT_CONFIG = {'allow_put_new_resource': True, 'allow_put_new_type_existing_resource': False, 'allow_put_remove_type_existing_resource': False}¶
- get(hashless_iri, accept_header='*/*', **kwargs)[source]¶
TODO: describe.
No support declaration required.
oldman.rest.crud module¶
- class oldman.rest.crud.HashLessCRUDer(manager)[source]¶
Bases: object
A HashlessCRUDer object helps you to manipulate your Resource objects in a RESTful-like manner.
Please note that REST/HTTP only manipulates hash-less IRIs. A hash IRI is the combination of a hash-less IRI (fragment-less IRI) and a fragment. Multiple hashed IRIs may have the same hash-less IRI and only differ by their fragment values. This is a concern for each type of HTTP operation.
This class is generic and does not support the Collection pattern (there is no append method).
Parameters: manager – ResourceManager object. Possible improvements:
- Add a PATCH method.
- delete(hashless_iri)[source]¶
Deletes every Resource object having this hash-less IRI.
Parameters: hashless_iri – Hash-less IRI.
- get(hashless_iri, content_type='text/turtle')[source]¶
Gets the main Resource object having its hash-less IRI.
When multiple Resource objects have this hash-less IRI, one of them has to be selected. If one has no fragment value, it is selected. Otherwise, this selection is currently arbitrary.
TODO: stop selecting the resources and returns the graph containing these resources.
Raises an ObjectNotFoundError exception if no resource is found.
Parameters: - hashless_iri – hash-less of the resource.
- content_type – Content type of its representation.
Returns: The representation of selected Resource object and its content type
- update(hashless_iri, document_content, content_type, allow_new_type=False, allow_type_removal=False)[source]¶
Updates every Resource object having this hash-less IRI.
Raises an OMDifferentBaseIRIError exception if tries to create of modify non-blank Resource objects that have a different hash-less IRI. This restriction is motivated by security concerns.
Accepts JSON, JSON-LD and RDF formats supported by RDFlib.
Parameters: - hashless_iri – Document IRI.
- document_content – Payload.
- content_type – Content type of the payload.
- allow_new_type – If True, new types can be added. Defaults to False. See oldman.resource.Resource.full_update() for explanations about the security concerns.
- allow_type_removal – If True, new types can be removed. Same security concerns than above. Defaults to False.