Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
path: root/sugar_network/db/index.py
diff options
context:
space:
mode:
authorAleksey Lim <alsroot@sugarlabs.org>2014-02-02 09:29:43 (GMT)
committer Aleksey Lim <alsroot@sugarlabs.org>2014-02-02 09:29:43 (GMT)
commit726ac1d66321ee7ac6b4cc7eff17001b5aeb6c5e (patch)
tree76416a704a112f70b9f8ce73833054ddd55a680f /sugar_network/db/index.py
parentde24419942178dbf17acd9311d0c0edf8d49be17 (diff)
Smplify raiting resource property
Diffstat (limited to 'sugar_network/db/index.py')
-rw-r--r--sugar_network/db/index.py16
1 files changed, 8 insertions, 8 deletions
diff --git a/sugar_network/db/index.py b/sugar_network/db/index.py
index 824423a..aa75f80 100644
--- a/sugar_network/db/index.py
+++ b/sugar_network/db/index.py
@@ -201,7 +201,7 @@ class IndexReader(object):
parser.add_prefix(name, prop.prefix)
parser.add_prefix('', prop.prefix)
if prop.slot is not None and \
- prop.typecast in [int, float, bool]:
+ prop.sortable_serialise is not None:
value_range = xapian.NumberValueRangeProcessor(
prop.slot, name + ':')
parser.add_valuerangeprocessor(value_range)
@@ -359,14 +359,14 @@ class IndexWriter(IndexReader):
else properties.get(name, prop.default)
if prop.slot is not None:
- if prop.typecast in [int, float, bool]:
- value_ = xapian.sortable_serialise(value)
+ if prop.sortable_serialise is not None:
+ slotted_value = xapian.sortable_serialise(
+ prop.sortable_serialise(value))
+ elif prop.localized:
+ slotted_value = toolkit.gettext(value) or ''
else:
- if prop.localized:
- value_ = toolkit.gettext(value) or ''
- else:
- value_ = next(_fmt_prop_value(prop, value))
- document.add_value(prop.slot, value_)
+ slotted_value = next(_fmt_prop_value(prop, value))
+ document.add_value(prop.slot, slotted_value)
if prop.prefix or prop.full_text:
for value_ in _fmt_prop_value(prop, value):