summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSam Thursfield <sam.thursfield@codethink.co.uk>2015-07-02 15:52:15 +0100
committerSam Thursfield <sam.thursfield@codethink.co.uk>2015-07-02 15:52:15 +0100
commit946cd28952621cae34436b7f9a67eb101fb60cff (patch)
tree2f3b45c71f903d6175f7af5bddd5f2dbf291f741
parentef2db0d6e95825cea4e6ef019cb8b8e912f3dd69 (diff)
downloaddefinitions-946cd28952621cae34436b7f9a67eb101fb60cff.tar.gz
schema: Clean up parse.py
Change-Id: I8f196f052fc5bbd7b26cc2b1800d497951357464
-rw-r--r--schema/parse.py34
1 files changed, 22 insertions, 12 deletions
diff --git a/schema/parse.py b/schema/parse.py
index 22f88645..36d09466 100644
--- a/schema/parse.py
+++ b/schema/parse.py
@@ -1,6 +1,15 @@
# Load Baserock Definitions serialisation format V5 into a SurfRDF 'store'.
-# https://github.com/cosminbasca/surfrdf
+# SurfRDF: https://github.com/cosminbasca/surfrdf
+
+# I've now decided that using RDFLib (a lower-level library used by SurfRDF)
+# directly would be just as simple as using the object-mapping provided by
+# SurfRDF. The rdflib.resource.Resource class is actually a pretty good
+# object-mapper itself, if we want one.
+
+# Note that neither surf.Resource nor rdflib.resource.Resource do any
+# validation of what properties you set according to the schema. You can
+# set chunk.baserock_dogfood='http://delicious' if you want.
import rdflib
@@ -59,7 +68,7 @@ def load_all_morphologies(session, store, path='.'):
chunk_uri = base_uri + 'chunks/' + contents['name']
entity = chunk = Chunk(chunk_uri)
- # FIXME: I think order is lost here !!!!!
+ # FIXME: order is lost here !!!!!
if 'pre-configure-commands' in contents:
chunk.baserock_preConfigureCommands = contents['pre-configure-commands']
if 'configure-commands' in contents:
@@ -169,8 +178,6 @@ def load_all_morphologies(session, store, path='.'):
deployments = []
for entry in contents.get('systems', []):
- # FIXME: can't get the URI from the 'morph' entry... need to load
- # the actual .morph file and get the name from there.
system_morph_file = os.path.join(toplevel_path, entry['morph'])
system_name = get_name_from_morph_file(system_morph_file)
system_uri = base_uri + 'systems/' + system_name
@@ -223,16 +230,19 @@ def load_all_morphologies(session, store, path='.'):
try:
session.commit()
except Exception as e:
+ # Special handler for a common error case when trying to insert data
+ # into a fresh install of the Virtuoso database... hopefully this saves
+ # someone time!
if 'Virtuoso 42000 Error SR186: No permission to execute procedure DB' in e.message:
print("Permission denied trying to update the database via the "
- "SPARQL endpoint. By default this endpoint is read-only. "
- "To enable write access, run the `isql` or `isql-vt` "
- "commandline interface and run the following statement:\n\n"
- " grant SPARQL_UPDATE to \"SPARQL\";\n\n"
- "WARNING! Only do this if you're using a local test instance "
- "of Virtuoso. You need to set up a real authenticated user "
- "account if using an instance of Virtuoso that has "
- "important data on it.")
+ "SPARQL endpoint. By default this endpoint is read-only. "
+ "To enable write access, run the `isql` or `isql-vt` "
+ "commandline interface and run the following statement:\n\n"
+ " grant SPARQL_UPDATE to \"SPARQL\";\n\n"
+ "WARNING! Only do this if you're using a local test instance "
+ "of Virtuoso. You need to set up a real authenticated user "
+ "account if using an instance of Virtuoso that has "
+ "important data on it.")
else:
raise