Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rwxr-xr-xbin/datastore-service10
-rw-r--r--src/olpc/datastore/backingstore.py14
-rw-r--r--src/olpc/datastore/datastore.py11
-rw-r--r--src/olpc/datastore/query.py2
4 files changed, 21 insertions, 16 deletions
diff --git a/bin/datastore-service b/bin/datastore-service
index dc3af92..955a508 100755
--- a/bin/datastore-service
+++ b/bin/datastore-service
@@ -3,7 +3,7 @@ import sys, os, signal
import gobject
import dbus.service
import dbus.mainloop.glib
-from olpc.datastore import DataStore, DS_LOG_CHANNEL
+from olpc.datastore import DataStore, DS_LOG_CHANNEL, backingstore
from olpc.datastore.indexer import INDEX_SERVICE, INDEX_OBJECT_PATH
import logging
@@ -11,7 +11,6 @@ import logging
profile = os.environ.get('SUGAR_PROFILE', 'default')
base_dir = os.path.join(os.path.expanduser('~'), '.sugar', profile)
repo_dir = os.path.join(base_dir, 'datastore')
-db_dir = "sqlite:///%s/datastore.db" % repo_dir
# operate from the repo directory
if not os.path.exists(repo_dir): os.makedirs(repo_dir)
@@ -48,10 +47,13 @@ if not sys.stdin.isatty():
# build the datastore
dbus.mainloop.glib.DBusGMainLoop(set_as_default=True)
bus = dbus.SessionBus()
-ds = DataStore(repo_dir, db_dir, querymanager_sync_index=False)
+
+ds = DataStore(querymanager_sync_index=False)
+ds.registerBackend(backingstore.FileBackingStore)
+ds.mount(repo_dir)
# and run it
-logger.info("Starting Datastore %s:%s" % (repo_dir, db_dir))
+logger.info("Starting Datastore %s" % (repo_dir))
mainloop = gobject.MainLoop()
def handle_shutdown(signum, frame):
diff --git a/src/olpc/datastore/backingstore.py b/src/olpc/datastore/backingstore.py
index 46bcb43..17d3c25 100644
--- a/src/olpc/datastore/backingstore.py
+++ b/src/olpc/datastore/backingstore.py
@@ -187,8 +187,8 @@ class FileBackingStore(BackingStore):
qm = query.DefaultQueryManager(index_name, **options)
# This will ensure the fulltext and so on are all assigned
- qm.prepare()
qm.bind_to(self)
+ qm.prepare()
self.create_descriptor(title=self.options.get('title', None))
self.querymanager = qm
@@ -198,12 +198,16 @@ class FileBackingStore(BackingStore):
# otherwise we will connect the global manager
# in load
index_name = os.path.join(self.base, self.INDEX_NAME)
- qm = query.DefaultQueryManager(index_name,
- **utils.options_for(self.options,
- 'querymanager_'))
+ if 'fulltext_repo' not in self.options:
+ self.options['fulltext_repo'] = os.path.join(self.uri,
+ query.DefaultQueryManager.FULLTEXT_NAME)
+
+ qm = query.DefaultQueryManager(index_name, **self.options)
+
# This will ensure the fulltext and so on are all assigned
- qm.prepare()
qm.bind_to(self)
+ qm.prepare()
+
self.querymanager = qm
def bind_to(self, datastore):
diff --git a/src/olpc/datastore/datastore.py b/src/olpc/datastore/datastore.py
index 30f7fcc..aaf9d0d 100644
--- a/src/olpc/datastore/datastore.py
+++ b/src/olpc/datastore/datastore.py
@@ -160,9 +160,8 @@ class DataStore(dbus.service.Object):
return [r.id for r in results]
- def _multiway_search(self, **kwargs):
- mountpoints = kwargs.pop('mountpoints',
- self.mountpoints)
+ def _multiway_search(self, query):
+ mountpoints = query.pop('mountpoints', self.mountpoints)
mountpoints = [self.mountpoints[m] for m in mountpoints]
results = []
# XXX: the merge will become *much* more complex in when
@@ -171,7 +170,7 @@ class DataStore(dbus.service.Object):
# collect
for mp in mountpoints:
- result, count = mp.find(kwargs)
+ result, count = mp.find(query)
results.append(result)
# merge
@@ -224,7 +223,7 @@ class DataStore(dbus.service.Object):
# distribute the search to all the mountpoints unless a
# backingstore id set is specified
- results, count = self._multiway_search(**kwargs)
+ results, count = self._multiway_search(kwargs)
# ordering is difficult when we are dealing with sets from
@@ -264,7 +263,7 @@ class DataStore(dbus.service.Object):
r.sort(comparator)
results = r
else:
- results = results.itervalues()
+ results = results.values()
d = []
for r in results:
diff --git a/src/olpc/datastore/query.py b/src/olpc/datastore/query.py
index e074202..fb27968 100644
--- a/src/olpc/datastore/query.py
+++ b/src/olpc/datastore/query.py
@@ -67,7 +67,7 @@ class QueryManager(object):
setattr(self, key, value)
def _handle_options(self, **kwargs):
- self._handle_option(kwargs, 'fulltext_repo', None)
+ self._handle_option(kwargs, 'fulltext_repo')
self._handle_option(kwargs, 'use_fulltext', True)
self._handle_option(kwargs, 'sync_index', True)
self._handle_option(kwargs, 'language', 'en')