Author: reinhard
Date: 2007-06-06 04:36:41 -0500 (Wed, 06 Jun 2007)
New Revision: 9676
Modified:
trunk/gnue-forms/src/GFObjects/GFField.py
Log:
Hack to allow looking up non-string keys (including None) in static lookup
datasources.
Modified: trunk/gnue-forms/src/GFObjects/GFField.py
===================================================================
--- trunk/gnue-forms/src/GFObjects/GFField.py 2007-06-06 09:20:13 UTC (rev 9675)
+++ trunk/gnue-forms/src/GFObjects/GFField.py 2007-06-06 09:36:41 UTC (rev 9676)
@@ -313,9 +313,9 @@
if value is None:
return None
- elif self._block.mode == 'query' and value.lower() == u_('(all)'):
+ elif self._block.mode == 'query' and value.lower() == u_("(all)"):
return ''
- elif self._block.mode == 'query' and value.lower() == u_('(empty)'):
+ elif self._block.mode == 'query' and value.lower() == u_("(empty)"):
return chr(0)
elif isinstance(value, datatypes.InvalidValueType):
return value
@@ -341,14 +341,23 @@
db_value = self.__get_value(offset)
if self._block.mode == 'query' and db_value == chr(0):
- return u_('(empty)')
- elif self._block.mode == 'query' and db_value in ['', None]:
- return u_('(all)')
+ return u_("(empty)")
+ elif self._block.mode == 'query' and db_value is None:
+ return u_("(all)")
- if self.__lookup_dict is None or db_value is None:
+ if self.__lookup_dict is None:
return None
elif db_value in self.__lookup_dict:
return self.__lookup_dict[db_value]
+ elif not isinstance(db_value, basestring) \
+ and str(db_value) in self.__lookup_dict:
+ # This is a workaround to allow lookups of boolean or numeric
+ # values in static lookup datasources.
+ return self.__lookup_dict[str(db_value)]
+ elif db_value is None:
+ # This is *after* the other checks so somebody can add "None"
+ # explicitly to the lookup source.
+ return None
else:
# db returned value that is actually not allowed
return u"(invalid)"
@@ -639,7 +648,7 @@
def __refresh_ui_choices(self):
if self._block.mode == 'query':
- lookup = [u_('(all)'), u_('(empty)')] + self.__lookup_list
+ lookup = [u_("(all)"), u_("(empty)")] + self.__lookup_list
if '' in lookup:
lookup.remove('')
else:
lmpx.com only provides a reader for public news (NNTP) servers. It is not
affiliated with the servers or forums shown here and is not responsible for
the content of articles, which is written by their respective authors.