As a newcomer to Solid, and preferring Python, I have written a few lines which print data from my pod using rdflib. Now I want to update my data and I can update the local graph, but cannot see any examples or documentation to show how to push the changes back into the pod.
Any guidance would be very much appreciated.
First things first, welcome to Solid!
It is true that right now, there is little support for Python in the Solid ecosystem. Solid is based on the LDP specification, if it can help. There are some “language-agnostic” examples on https://solidproject.org/for-developers/apps/common-patterns, but they are still quite limited (it is a work currently in progress).
A quick summary of what you’ll need (for more details, I think the LDP spec is a good resource):
- As there is no authentication client in python, make sure that the resources you manipulate are public on your Pod
- To retrieve a resource, perform a GET request
- To create a resource, issue a POST request to its parent, with the RDF content in the body. You may specify a
Slug header to name your resource, and
<http://www.w3.org/ns/ldp#RDFSource>; rel="type" in the
Link header. Be sure to include
text/turtle (or whatever is appropriate) in the
- To create a container, change the
Link header to
<http://www.w3.org/ns/ldp#BasicContainer>; rel="type". If the container is initially empty, the body of the Put may be something like
@prefix new: <>.
@prefix ldp: <http://www.w3.org/ns/ldp#>.
a ldp:BasicContainer, ldp:Container.
You can also create resources using PUT requests, this time not targeting its parent IRI but the IRI you want for the created resource. In short, to create /foo/bar/moo,
- POST to /foo/bar
- PUT to /foo/bar/moo
I know this is basic, but I hope that your experience will be valuable to other python developers that want to join Solid !