From 7397edbe2406e9796dccbbdc2d3202c23b3d9842 Mon Sep 17 00:00:00 2001 From: Benoit Seguin Date: Fri, 2 Dec 2016 20:00:27 +0100 Subject: [PATCH 1/3] Adding the option of using POST for sparql queries (even when they are not updates) --- rdflib/plugins/stores/sparqlstore.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/rdflib/plugins/stores/sparqlstore.py b/rdflib/plugins/stores/sparqlstore.py index 5a7032465..03d7f6f52 100644 --- a/rdflib/plugins/stores/sparqlstore.py +++ b/rdflib/plugins/stores/sparqlstore.py @@ -239,6 +239,7 @@ def __init__(self, sparql11=True, context_aware=True, node_to_sparql=_node_to_sparql, node_from_result=_node_from_result, + query_as_post=False, **sparqlwrapper_kwargs): """ """ @@ -259,6 +260,7 @@ def __init__(self, self.context_aware = context_aware self.graph_aware = context_aware self._timeout = None + self.query_as_post = query_as_post # Database Management Methods def create(self, configuration): @@ -322,6 +324,7 @@ def query(self, query, " ".join(self.node_to_sparql(initBindings[x]) for x in v)) self.resetQuery() + self.setMethod(POST if self.query_as_post else GET) if self._is_contextual(queryGraph): self.addParameter("default-graph-uri", queryGraph) self.timeout = self._timeout From 6108746b2f202e2b4d26909fcda901351d8c8597 Mon Sep 17 00:00:00 2001 From: Benoit Seguin Date: Sun, 4 Dec 2016 22:51:19 +0100 Subject: [PATCH 2/3] Corrections asked by @joernhees --- rdflib/plugins/stores/sparqlstore.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/rdflib/plugins/stores/sparqlstore.py b/rdflib/plugins/stores/sparqlstore.py index 03d7f6f52..f21b880bd 100644 --- a/rdflib/plugins/stores/sparqlstore.py +++ b/rdflib/plugins/stores/sparqlstore.py @@ -239,7 +239,7 @@ def __init__(self, sparql11=True, context_aware=True, node_to_sparql=_node_to_sparql, node_from_result=_node_from_result, - query_as_post=False, + default_query_method=GET, **sparqlwrapper_kwargs): """ """ @@ -260,7 +260,7 @@ def __init__(self, self.context_aware = context_aware self.graph_aware = context_aware self._timeout = None - self.query_as_post = query_as_post + self.default_query_method = default_query_method # Database Management Methods def create(self, configuration): @@ -324,7 +324,7 @@ def query(self, query, " ".join(self.node_to_sparql(initBindings[x]) for x in v)) self.resetQuery() - self.setMethod(POST if self.query_as_post else GET) + self.setMethod(self.default_query_method) if self._is_contextual(queryGraph): self.addParameter("default-graph-uri", queryGraph) self.timeout = self._timeout From 87f71daa0a3685b982b350394cde366af41de939 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B6rn=20Hees?= Date: Mon, 5 Dec 2016 11:36:58 +0100 Subject: [PATCH 3/3] renamed self.default_query_method to self.query_method default is set on init, actual query method might be changed during exec --- rdflib/plugins/stores/sparqlstore.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/rdflib/plugins/stores/sparqlstore.py b/rdflib/plugins/stores/sparqlstore.py index f21b880bd..25cfb61dc 100644 --- a/rdflib/plugins/stores/sparqlstore.py +++ b/rdflib/plugins/stores/sparqlstore.py @@ -260,7 +260,7 @@ def __init__(self, self.context_aware = context_aware self.graph_aware = context_aware self._timeout = None - self.default_query_method = default_query_method + self.query_method = default_query_method # Database Management Methods def create(self, configuration): @@ -324,7 +324,7 @@ def query(self, query, " ".join(self.node_to_sparql(initBindings[x]) for x in v)) self.resetQuery() - self.setMethod(self.default_query_method) + self.setMethod(self.query_method) if self._is_contextual(queryGraph): self.addParameter("default-graph-uri", queryGraph) self.timeout = self._timeout