Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
path: root/bin
diff options
context:
space:
mode:
authorBenjamin Saller <bcsaller@objectrealms.net>2007-06-20 01:38:44 (GMT)
committer Benjamin Saller <bcsaller@objectrealms.net>2007-06-20 01:38:44 (GMT)
commitb1699eb15c054b1766e66b6721c61201353f0a29 (patch)
treefd07699631d82a8b58e46571a71d01f0120b7134 /bin
parent31ade88ac9bc1fe95544a24ec1a0fe8525762fca (diff)
honor mimetype passed in by client
Diffstat (limited to 'bin')
-rwxr-xr-xbin/datastore2
-rwxr-xr-xbin/index-service7
-rwxr-xr-xbin/sample-client.py19
3 files changed, 19 insertions, 9 deletions
diff --git a/bin/datastore b/bin/datastore
index c50daf6..77aca84 100755
--- a/bin/datastore
+++ b/bin/datastore
@@ -1,4 +1,4 @@
-#!/usr/bin/env python2.4
+#!/usr/bin/env python
from ore.main import Application
from olpc.datastore import DataStore
from olpc.datastore.indexer import INDEX_SERVICE, INDEX_OBJECT_PATH
diff --git a/bin/index-service b/bin/index-service
index 14a71d7..6a7fc2d 100755
--- a/bin/index-service
+++ b/bin/index-service
@@ -83,7 +83,8 @@ class IndexService(Application):
filename = self.ds.get_filename(uid)
r = None
if filename:
- r = self.fulltext.fulltext_index(uid, filename)
+ mime_type = self.ds.get_properties(uid).get('mime_type', None)
+ r = self.fulltext.fulltext_index(uid, filename, mime_type)
if r is True:
logger.debug("index creation of %s" % uid)
elif r is False:
@@ -99,7 +100,9 @@ class IndexService(Application):
filename = self.ds.get_filename(uid)
r = None
if filename:
- r = self.fulltext.fulltext_index(uid, 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)
if r is True:
logger.debug("index update of %s" % uid)
elif r is False:
diff --git a/bin/sample-client.py b/bin/sample-client.py
index 9fc3f10..1a2475d 100755
--- a/bin/sample-client.py
+++ b/bin/sample-client.py
@@ -12,22 +12,29 @@ 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()
print "find", datastore.find(dict(author="Benjamin", title="from"))
res, count = datastore.find(dict(fulltext="peek"))
if not res:
print "unable to index content"
- return
- item = res[0]
- print "bcsaller", item['uid']
+ #return
+ print "bcsaller", [item['uid'] for item in res]
print "huh?", datastore.find(dict(fulltext="kfdshaksjd"))
# try the other mimetypes
- datastore.update(uid, dict(title="updated title"), os.path.abspath('tests/test.doc'))
- datastore.update(uid, dict(title="another updated title"), os.path.abspath('tests/test.odt'))
+ datastore.update(uid, dict(title="updated title", mime_type="application/msword"), os.path.abspath('tests/test.doc'))
+ 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.get_properties(uid)
+
datastore.delete(uid)
if __name__ == '__main__':