Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
path: root/creactistore/_templates/lib/semanticxo/sparql.py
diff options
context:
space:
mode:
authorflorent <florent@toopy.org>2012-02-06 23:01:40 (GMT)
committer florent <florent@toopy.org>2012-02-06 23:01:40 (GMT)
commit197d0dd4a7c76d36e56c8e426f23dd4bbc301fdd (patch)
tree3d3ad9cc46d7ffc3760e950db0061c02cab16d8e /creactistore/_templates/lib/semanticxo/sparql.py
parenta7d68ceb5bf576320df47e690205122ec6db8e4c (diff)
use more generic way to init creatistore project using buildout → need to work on the packaging issue now and update others templatesHEADmaster
Diffstat (limited to 'creactistore/_templates/lib/semanticxo/sparql.py')
-rw-r--r--creactistore/_templates/lib/semanticxo/sparql.py42
1 files changed, 0 insertions, 42 deletions
diff --git a/creactistore/_templates/lib/semanticxo/sparql.py b/creactistore/_templates/lib/semanticxo/sparql.py
deleted file mode 100644
index 2a24a20..0000000
--- a/creactistore/_templates/lib/semanticxo/sparql.py
+++ /dev/null
@@ -1,42 +0,0 @@
-'''
-Created on 25 Aug 2011
-
-@author: cgueret
-'''
-# python import
-import httplib, urllib, cjson
-
-# rdflib import
-from rdflib import URIRef, Literal
-
-
-class SPARQL(object):
-
- def __init__(self, url):
- self._url = url
-
- def execute_select(self, query):
- results = []
- params = {'query': query, 'format' : 'json'}
- headers = {'Content-Type': 'application/x-www-form-urlencoded'}
- try:
- # Open the connection
- conn = httplib.HTTPConnection(self._url)
- conn.request("POST", "/sparql", urllib.urlencode(params), headers=headers)
- # Get the results
- response = conn.getresponse()
- r = cjson.decode(response.read(), all_unicode=False)
- # Recode them
- for entry in r['results']['bindings']:
- result = {}
- for (name,data) in entry.iteritems():
- value = Literal(data['value'])
- if data['type']=='uri':
- value = URIRef(data['value'])
- result[name] = value
- results.append(result)
- conn.close()
- except:
- pass
- # returns select results or empty list
- return results