Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMarco Pesenti Gritti <marco@localhost.localdomain>2007-07-20 18:49:26 (GMT)
committer Marco Pesenti Gritti <marco@localhost.localdomain>2007-07-20 18:49:26 (GMT)
commitf26b551befa7d27aa6aa1736b8a68775965dd80e (patch)
tree34cef0bc735a0c4469b84dd9d58c34475612c352
parent3924afa8371688129f171e6e1f025eb92028d4e9 (diff)
parent9a44a5bafb391faa57a58efdc0f6d451221c9d45 (diff)
Merge branch 'master' of git+ssh://dev.laptop.org/git/projects/datastore
-rw-r--r--src/olpc/datastore/model.py9
-rw-r--r--src/olpc/datastore/xapianindex.py2
-rw-r--r--tests/test_model.py8
3 files changed, 14 insertions, 5 deletions
diff --git a/src/olpc/datastore/model.py b/src/olpc/datastore/model.py
index 929c376..46f2225 100644
--- a/src/olpc/datastore/model.py
+++ b/src/olpc/datastore/model.py
@@ -202,8 +202,13 @@ class Content(object):
if isinstance(v, list) and len(v) == 1:
v = v[0]
field = self._model.fields.get(k)
- kind = propertyByKind(field[1])
- v = kind.from_xapian(v)
+ if field:
+ kind = propertyByKind(field[1])
+ v = kind.from_xapian(v)
+ else:
+ # do some generic property handling
+ if v: v = str(v)
+ else: v = ''
d[k] = v
return d
diff --git a/src/olpc/datastore/xapianindex.py b/src/olpc/datastore/xapianindex.py
index 46eca98..0be462d 100644
--- a/src/olpc/datastore/xapianindex.py
+++ b/src/olpc/datastore/xapianindex.py
@@ -343,7 +343,7 @@ class IndexManager(object):
q = query.pop('query', None)
if q:
queries.append(self.parse_query(q))
- if not query:
+ if not query and not queries:
# we emptied it
q = self.read_index.query_all()
else:
diff --git a/tests/test_model.py b/tests/test_model.py
index bb30426..a346510 100644
--- a/tests/test_model.py
+++ b/tests/test_model.py
@@ -107,12 +107,16 @@ class Test(unittest.TestCase):
ds.complete_indexing()
- ds.update(uid, {'title' : 'Random Extras the sequel', 'foobar' : 'whodofoodo',
+ ds.update(uid, {'title' : 'Random Extras the sequel',
+ 'foobar' : 'whodofoodo',
'incept:date' : datetime.datetime.now().isoformat()})
ds.complete_indexing()
- assert ds.find('whodofoodo')[1] == 1
+ # ignored w/o prefix
+ assert ds.find('whodofoodo')[1] == 0
+ # found with it
+ assert ds.find('foobar:whodofoodo')[1] == 1
c = ds.get_properties(uid)
assert 'foobar' in c
assert 'title' in c