KTBS API¶
I provide an implementation of the Abstract KTBS API.
This implementation is defined as a set of mix-in classes that rely on the
uniform interface of rdfrest.cores.ICore
. This allows to use
those classes in different ways:
- as local instances (for a standalone kTBS embeded in one’s application),
- as an HTTP client to a remote kTBS,
- or even as a client through any protocol implemented on top of
rdfrest
.
Extensions to the abstract API¶
I implement the following extensions to the default Abstract KTBS API.
Extensions suggested by the abstract API¶
- read-only or read-write properties corresponding to get/set methods
- read-only properties corresponding to list methods
- iter methods corresponding to list methods
Note also that those adaptations are automatically generated by the
extend_api()
class decorator.
Specific extensions for function parameters¶
- Anytime a kTBS element is expected, passing a URI should also work
(including a URI relative to the target object). For example, the ‘model’
argument of
create_stored_trace()
can be a URI (as a unicode or anURIRef
) rather than an instance ofTraceModel
. - Datetimes can be used instead of integers for representing timecodes in traces when the trace model and origin allow the conversion.
Specific extensions for creation methods¶
- The id parameter is specified in the Abstract KTBS API in all
creation methods: it is often optional but can be used to set the URI of the
resource to create (else, the KTBS will generate a URI). If provided, it must
of course be an acceptable URI (not already in use, and subordinated to the
parent’s URI). As specified by the Abstract KTBS API, id can be
provided as character string, representing a URI either absolute or relative
to the parent’s URI. The Python implementation also accepts a
rdflib.URIRef
or any object with a uri attribute returning aURIRef
. - Creation methods also accept an additional parameter graph where the user
can specify arbitrary properties for the resource to create. This assumes
that the resource can be identified in the graph, which is trivial is id is
provided. However, if the user wants to provide a graph but also wants to
let the KTBS mint a URI for the created resource, they can use a
blank node
) to represent the resource in graph, and pass it to id.