From 0cda1d5967f9ef41178be44e0751f3babe0d210b Mon Sep 17 00:00:00 2001 From: Benjamin Saller Date: Tue, 17 Jul 2007 00:03:00 +0000 Subject: make sure non-model properties make it into the result set --- diff --git a/src/olpc/datastore/xapianindex.py b/src/olpc/datastore/xapianindex.py index 49448d7..b104d44 100644 --- a/src/olpc/datastore/xapianindex.py +++ b/src/olpc/datastore/xapianindex.py @@ -235,11 +235,19 @@ class IndexManager(object): to Property objects """ d = {} + add_anything = False for k,v in props.iteritems(): p, added = self.datamodel.fromstring(k, v, allowAddition=True) - if added is True: self.fields.add(p.key) + if added is True: + self.fields.add(p.key) + add_anything = True d[p.key] = p + + if add_anything: + with self._write_lock: + self.datamodel.apply(self) + return d def index(self, props, filename=None): diff --git a/tests/test_model.py b/tests/test_model.py index 618c5cb..bb30426 100644 --- a/tests/test_model.py +++ b/tests/test_model.py @@ -113,6 +113,12 @@ class Test(unittest.TestCase): ds.complete_indexing() assert ds.find('whodofoodo')[1] == 1 + c = ds.get_properties(uid) + assert 'foobar' in c + assert 'title' in c + # maps back w/o the type + assert 'incept' in c + ds.stop() -- cgit v0.9.1