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-13 03:14:21 (GMT)
committer Benjamin Saller <bcsaller@objectrealms.net>2007-07-13 03:14:21 (GMT)
commitfded7518d44197dd109cdeb891a73bcf7dd55613 (patch)
tree12787d84e7e15c4ddadacde009e292b97868dcb2
parent6180ddc862188ba3728b43f8f4b74f73b077f3da (diff)
sample client dbus interface verified
-rwxr-xr-xbin/datastore-service6
-rwxr-xr-xbin/sample-client.py15
-rw-r--r--src/olpc/datastore/datastore.py17
3 files changed, 14 insertions, 24 deletions
diff --git a/bin/datastore-service b/bin/datastore-service
index b21e529..532516b 100755
--- a/bin/datastore-service
+++ b/bin/datastore-service
@@ -4,7 +4,6 @@ import gobject
import dbus.service
import dbus.mainloop.glib
from olpc.datastore import DataStore, DS_LOG_CHANNEL, backingstore
-from olpc.datastore.indexer import INDEX_SERVICE, INDEX_OBJECT_PATH
import logging
SYNC_INDEX = True
@@ -32,8 +31,6 @@ logging.basicConfig(level=logging.DEBUG,
filename = filename,
)
# disable subsystem logging except where critical
-logging.getLogger('sqlalchemy').setLevel(logging.CRITICAL)
-logging.getLogger('lemur').setLevel(logging.CRITICAL)
logger = logging.getLogger(DS_LOG_CHANNEL)
# check for old lockfiles, the rules here are that we can't be
@@ -68,9 +65,6 @@ signal.signal(signal.SIGHUP, handle_shutdown)
signal.signal(signal.SIGTERM, handle_shutdown)
def main():
- if SYNC_INDEX is False:
- indexer = bus.get_object(INDEX_SERVICE, INDEX_OBJECT_PATH)
-
try: mainloop.run()
except KeyboardInterrupt:
ds.stop()
diff --git a/bin/sample-client.py b/bin/sample-client.py
index bd609a7..7dc1501 100755
--- a/bin/sample-client.py
+++ b/bin/sample-client.py
@@ -2,7 +2,6 @@
from ore.main import Application
import dbus
import os
-import time
def main():
bus = dbus.SessionBus()
@@ -12,13 +11,8 @@ def main():
uid = datastore.create(dict(title="from dbus", author="Benjamin"), os.path.abspath('tests/test.pdf'))
print "created uid", uid
-
- #for u in datastore.find()[0]:
- # datastore.delete(u['uid'])
- #return
- # let the async indexer run
- time.sleep(1.2)
- #import pdb;pdb.set_trace()
+ datastore.complete_indexing()
+
print "find", datastore.find(dict(author="Benjamin", title="from"))
res, count = datastore.find(dict(fulltext="peek"))
if not res:
@@ -33,11 +27,14 @@ def main():
print datastore.find(dict(fulltext="inside"))
datastore.update(uid, dict(title="another updated title", mime_type="application/vnd.oasis.opendocument.text"), os.path.abspath('tests/test.odt'))
print datastore.find(dict(fulltext="amazed"))
+
+ datastore.complete_indexing()
datastore.get_properties(uid)
- print "title in fulltext", datastore.find(dict(fulltext="another"))
+ print "title in fulltext", datastore.find(dict(title="another"))
datastore.delete(uid)
+ datastore.complete_indexing()
if __name__ == '__main__':
#a = Application("client", main)
diff --git a/src/olpc/datastore/datastore.py b/src/olpc/datastore/datastore.py
index 2429637..9121be9 100644
--- a/src/olpc/datastore/datastore.py
+++ b/src/olpc/datastore/datastore.py
@@ -343,15 +343,11 @@ class DataStore(dbus.service.Object):
#@utils.sanitize_dbus
@dbus.service.method(DS_DBUS_INTERFACE,
- in_signature='sa{sv}',
+ in_signature='s',
out_signature='a{sv}')
- def get_properties(self, uid, query=None):
+ def get_properties(self, uid):
content = self.get(uid)
- dictionary = {}
- if not query: query = {}
- for prop in content.get_properties(query):
- dictionary[prop.key] = prop.marshall()
- return dictionary
+ return content.properties
@dbus.service.method(DS_DBUS_INTERFACE,
in_signature='sa{sv}',
@@ -410,9 +406,12 @@ class DataStore(dbus.service.Object):
@dbus.service.signal(DS_DBUS_INTERFACE)
def Stopped(self): pass
-
+ @dbus.service.method(DS_DBUS_INTERFACE,
+ in_signature='',
+ out_signature='')
def complete_indexing(self):
- """Block waiting for all queued indexing operations to complete"""
+ """Block waiting for all queued indexing operations to
+ complete. Used mostly in testing"""
for mp in self.mountpoints.itervalues():
mp.complete_indexing()