From 9a44a5bafb391faa57a58efdc0f6d451221c9d45 Mon Sep 17 00:00:00 2001 From: Benjamin Saller Date: Fri, 20 Jul 2007 18:51:56 +0000 Subject: help insolate vs unspecified properties --- diff --git a/src/olpc/datastore/model.py b/src/olpc/datastore/model.py index 9ff2e1f..9f51cf6 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/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 -- cgit v0.9.1