Namespace handling tweaks, using split_uri from rdflib.namespace instead of basic string split on #, and now checking if namespace is CATEGORY_NAMESPACE in config.
--- a/src/catedit/utils.py Fri Apr 17 11:45:08 2015 +0200
+++ b/src/catedit/utils.py Fri Apr 17 15:49:08 2015 +0200
@@ -10,6 +10,7 @@
from flask import session
from rdflib import RDF, RDFS, URIRef
from rdflib.compare import to_isomorphic, graph_diff
+from rdflib.namespace import split_uri
from flask.ext.github import GitHubError
@@ -48,7 +49,7 @@
compare_result["same_content"] = (
first_iso_cat == second_iso_cat
)
-
+
if not(compare_result["same_content"]) and with_details:
rdf_in_both = []
rdf_only_in_first = []
@@ -69,6 +70,7 @@
(in_second, rdf_only_in_second)
]:
for triple in diff_list.triples((None, None, None)):
+ logger.debug(triple)
if triple[1] == RDFS.label:
final_list.append(("label", triple[2].toPython()))
elif triple[1] == RDF.Description:
@@ -90,12 +92,20 @@
)
)
else:
- final_list.append(
- (
- predicate,
- triple[2].toPython().split("#", 1)[1]
+ can_append = True
+ try:
+ namespace, _ = split_uri(triple[2])
+ if namespace != app.config["CATEGORY_NAMESPACE"]:
+ can_append = False
+ except:
+ can_append = False
+ if can_append:
+ final_list.append(
+ (
+ predicate,
+ split_uri(triple[2])[1]
+ )
)
- )
compare_result["only_in_first"] = in_first
compare_result["only_in_second"] = in_second
compare_result["in_both"] = in_both
--- a/src/catedit/views/categories.py Fri Apr 17 11:45:08 2015 +0200
+++ b/src/catedit/views/categories.py Fri Apr 17 15:49:08 2015 +0200
@@ -14,6 +14,7 @@
from flask import render_template, request, redirect, url_for, abort, Blueprint
from rdflib import Graph
+from rdflib.namespace import split_uri
from catedit.views.forms import CommitForm, CategoryForm
@@ -299,9 +300,11 @@
for (cat_predicate, cat_object) in current_cat_properties:
can_append = True
if get_property_list()[repository][cat_predicate.toPython()]["object_type"] == "uriref-category":
- if "#" in cat_object:
- namespace, object_id = cat_object.split("#", 1)
- else:
+ try:
+ namespace, object_id = split_uri(cat_object)
+ if namespace != app.config["CATEGORY_NAMESPACE"]:
+ can_append = False
+ except:
can_append = False
else:
object_id = cat_object
--- a/src/catedit/views/social.py Fri Apr 17 11:45:08 2015 +0200
+++ b/src/catedit/views/social.py Fri Apr 17 15:49:08 2015 +0200
@@ -159,7 +159,6 @@
}
changes_details = None
- print(str(details_cat_id))
if details_cat_id is not None:
if (
details_cat_id not in [category.cat_id