Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBenjamin Saller <bcsaller@objectrealms.net>2007-07-04 20:58:54 (GMT)
committer Benjamin Saller <bcsaller@objectrealms.net>2007-07-04 20:58:54 (GMT)
commit649ec3d6f8e566d185eea91b22ce5a36b3e93dc1 (patch)
tree179f3fd511d72e2a1600170a207454a6d2eb5e00
parent3663a1e945a2ab03d731fe183535a04b6261196e (diff)
fix 1882
patch 1889
-rwxr-xr-xbin/index-service17
-rwxr-xr-xbin/sample-client.py2
-rw-r--r--src/olpc/datastore/datastore.py35
-rw-r--r--src/olpc/datastore/indexer.py1
4 files changed, 47 insertions, 8 deletions
diff --git a/bin/index-service b/bin/index-service
index 6a7fc2d..4529913 100755
--- a/bin/index-service
+++ b/bin/index-service
@@ -75,6 +75,15 @@ class IndexService(Application):
self.eventloop.run()
+ def get_textprops(self, uid):
+ # text properties also get full text indexing
+ # currently this is still searched with the 'fulltext'
+ # parameter of find()
+ textprops = {}
+ for p in self.ds.get_properties(uid, type='text'):
+ textprops[p.key] = p.value and p.value or ''
+ return textprops
+
def created(self, uid):
"""An object was created on the bus and we want to index it"""
# because the file isn't encoded anywhere accessible in the
@@ -84,7 +93,8 @@ class IndexService(Application):
r = None
if filename:
mime_type = self.ds.get_properties(uid).get('mime_type', None)
- r = self.fulltext.fulltext_index(uid, filename, mime_type)
+ r = self.fulltext.fulltext_index(uid, filename, mime_type,
+ **self.get_textprops(uid))
if r is True:
logger.debug("index creation of %s" % uid)
elif r is False:
@@ -102,7 +112,8 @@ class IndexService(Application):
if filename:
mime_type = self.ds.get_properties(uid).get('mime_type', None)
print uid, filename, mime_type
- r = self.fulltext.fulltext_index(uid, filename, mime_type)
+ r = self.fulltext.fulltext_index(uid, filename, mime_type,
+ **self.get_textprops(uid))
if r is True:
logger.debug("index update of %s" % uid)
elif r is False:
@@ -139,7 +150,7 @@ if __name__ == "__main__":
signal.signal(signal.SIGTERM, handle_shutdown)
idx = IndexService()
- ##idx()
+ #idx()
# w/o ore.main
import gobject
diff --git a/bin/sample-client.py b/bin/sample-client.py
index 1a2475d..bd609a7 100755
--- a/bin/sample-client.py
+++ b/bin/sample-client.py
@@ -35,6 +35,8 @@ def main():
print datastore.find(dict(fulltext="amazed"))
datastore.get_properties(uid)
+ print "title in fulltext", datastore.find(dict(fulltext="another"))
+
datastore.delete(uid)
if __name__ == '__main__':
diff --git a/src/olpc/datastore/datastore.py b/src/olpc/datastore/datastore.py
index b4fe356..142d801 100644
--- a/src/olpc/datastore/datastore.py
+++ b/src/olpc/datastore/datastore.py
@@ -109,6 +109,24 @@ class DataStore(dbus.service.Object):
self.mountpoints[mountpoint_id].stop()
del self.mountpoints[mountpoint_id]
### End Mount Points
+
+ ### Buddy Management
+ ## A single datastore typically refers to a single user
+ ## this breaks down a little in the case of things like USB
+ ## sticks and so on. We provide a facility for tracking
+ ## co-authors of content
+ ## there are associated changes to 'find' to resolve buddies
+ def addBuddy(self, id, name, fg_color, bg_color):
+ pass
+
+ def getBuddy(self, id):
+ pass
+
+ def buddies(self):
+ pass
+
+
+ ## end buddy api
def connect_backingstore(self, uri, **kwargs):
"""
@@ -227,6 +245,13 @@ class DataStore(dbus.service.Object):
don't want to generate them unless needed. In the case the
the full properties set matches doing the single roundtrip
to start an activity makes sense.
+
+ To order results by a given property you can specify:
+ >>> ds.find(order_by=['author', 'title'])
+
+ Order by must be a list of property names given in the order
+ of decreasing precedence.
+
"""
# only goes to the primary now. Punting on the merge case
if isinstance(query, dict):
@@ -234,7 +259,7 @@ class DataStore(dbus.service.Object):
include_files = kwargs.pop('include_files', False)
order_by = kwargs.pop('order_by', [])
-
+
# distribute the search to all the mountpoints unless a
# backingstore id set is specified
results, count = self._multiway_search(kwargs)
@@ -272,7 +297,6 @@ class DataStore(dbus.service.Object):
return 0
-
r = results.values()
r.sort(comparator)
results = r
@@ -330,12 +354,13 @@ class DataStore(dbus.service.Object):
#@utils.sanitize_dbus
@dbus.service.method(DS_DBUS_INTERFACE,
- in_signature='s',
+ in_signature='sa{sv}',
out_signature='a{sv}')
- def get_properties(self, uid):
+ def get_properties(self, uid, query=None):
content = self.get(uid)
dictionary = {}
- for prop in content.get_properties():
+ if not query: query = {}
+ for prop in content.get_properties(**query):
dictionary[prop.key] = prop.marshall()
return dictionary
diff --git a/src/olpc/datastore/indexer.py b/src/olpc/datastore/indexer.py
index 8d132ad..de7ef33 100644
--- a/src/olpc/datastore/indexer.py
+++ b/src/olpc/datastore/indexer.py
@@ -44,3 +44,4 @@ class Indexer(dbus.service.Object, XapianFulltext):
self.connect_fulltext(repo, read_only=False)
+