Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChristophe Gueret <christophe.gueret@gmail.com>2011-05-13 17:24:48 (GMT)
committer Christophe Gueret <christophe.gueret@gmail.com>2011-05-13 17:24:48 (GMT)
commitb0badbaae35f55ae5b0b1b347602315f978f8c98 (patch)
treedc7bd598e9139cdcdd32651f89d09a455a2a8170
parent37bea560e5661711f7c683282cc5d1c2b7e22dd7 (diff)
Edit
l---------removed/metadatareader.so1
-rw-r--r--src/semanticxo/indexstore.py16
-rw-r--r--src/semanticxo/metadatastore.py13
3 files changed, 18 insertions, 12 deletions
diff --git a/removed/metadatareader.so b/removed/metadatareader.so
deleted file mode 120000
index bf6931a..0000000
--- a/removed/metadatareader.so
+++ /dev/null
@@ -1 +0,0 @@
-.libs/metadatareader.so \ No newline at end of file
diff --git a/src/semanticxo/indexstore.py b/src/semanticxo/indexstore.py
index 6e65174..50298e0 100644
--- a/src/semanticxo/indexstore.py
+++ b/src/semanticxo/indexstore.py
@@ -191,9 +191,9 @@ class QueryParser (xapian.QueryParser):
try:
return xapian.QueryParser.parse_query(
self, query_str,
- QueryParser.FLAG_PHRASE |
- QueryParser.FLAG_BOOLEAN |
- QueryParser.FLAG_LOVEHATE |
+ QueryParser.FLAG_PHRASE |
+ QueryParser.FLAG_BOOLEAN |
+ QueryParser.FLAG_LOVEHATE |
QueryParser.FLAG_WILDCARD,
'')
@@ -228,10 +228,12 @@ class QueryParser (xapian.QueryParser):
class IndexStore(object):
- """Index metadata and provide rich query facilities on it.
- """
+ '''
+ Index metadata and provide rich query facilities on it.
+ '''
def __init__(self):
+ self._url = '127.0.0.1:8080'
self._database = None
self._flush_timeout = None
self._pending_writes = 0
@@ -279,9 +281,12 @@ class IndexStore(object):
query_parser = QueryParser()
query_parser.set_database(self._database)
+
enquire = Enquire(self._database)
enquire.set_query(query_parser.parse_query(query, query_string))
+ # TODO Convert query string into regexp based on any property
+
# This will assure that the results count is exact.
check_at_least = offset + limit + 1
@@ -290,6 +295,7 @@ class IndexStore(object):
else:
order_by = order_by[0]
+ # TODO Convert order by into SPARQL ORDER BY clause (map word to URI and adjust +-)
if order_by == '+timestamp':
enquire.set_sort_by_value(_VALUE_TIMESTAMP, True)
elif order_by == '-timestamp':
diff --git a/src/semanticxo/metadatastore.py b/src/semanticxo/metadatastore.py
index 471f5b0..f6f9081 100644
--- a/src/semanticxo/metadatastore.py
+++ b/src/semanticxo/metadatastore.py
@@ -13,7 +13,7 @@ OLPC_TERMS = Namespace("http://example.org/terms#")
class MetadataStore(object):
'''
- classdocs
+ Store metadata into the triple store using HTTP calls.
'''
def __init__(self):
self._url = '127.0.0.1:8080'
@@ -43,14 +43,14 @@ class MetadataStore(object):
# Compose and save the graph
graph = ConjunctiveGraph()
resource = self._get_resource(uid)
+ graph.add((resource, RDF.type, OLPC_TERMS['DSObject']))
for key, value in props.items():
- if isinstance(key, basestring) or isinstance(key, unicode):
+ if isinstance(key, basestring) and isinstance(value, basestring):
key = OLPC_TERMS[key]
- if isinstance(value, basestring) or isinstance(value, unicode):
- graph.add((resource, key, Literal(value)))
+ value = Literal(value)
+ graph.add((resource, key, value))
# Save it
- print graph.serialize()
headers = { 'Accept' : '*/*', 'Content-Type': 'application/rdf+xml' }
conn = httplib.HTTPConnection(self._url)
conn.request("PUT", "/data/%s" % resource, body=graph.serialize(), headers=headers)
@@ -65,9 +65,10 @@ class MetadataStore(object):
for line in self._sparql_get(query):
print line
- # This is expected to be always present
+ # HACK: This is expected to be always present
if 'creation_time' not in props:
props['creation_time'] = int(time.time())
+
return props
def delete(self, uid):