diff --git a/src/wuttaweb/grids/filters.py b/src/wuttaweb/grids/filters.py index 54fce1c..f34d848 100644 --- a/src/wuttaweb/grids/filters.py +++ b/src/wuttaweb/grids/filters.py @@ -350,6 +350,26 @@ class GridFilter: # pylint: disable=too-many-instance-attributes return normalized + def coerce_value(self, value): + """ + Coerce the given value to the correct type/format for use with + the filter. This is where e.g. a boolean or date filter + should convert input string to ``bool`` or ``date`` value. + + This is (usually) called from a filter method, when applying + the filter. See also :meth:`apply_filter()`. + + Default logic on the base class returns value as-is; subclass + may override as needed. + + :param value: Input string provided by the user via the filter + form submission. + + :returns: Value of the appropriate type, depending on the + filter subclass. + """ + return value + def apply_filter(self, data, verb=None, value=UNSPECIFIED): """ Filter the given data set according to a verb/value pair. @@ -420,15 +440,6 @@ class AlchemyFilter(GridFilter): if len(columns) == 1: self.nullable = columns[0].nullable - def coerce_value(self, value): - """ - Coerce the given value to the correct type/format for use with - the filter. - - Default logic returns value as-is; subclass may override. - """ - return value - def filter_equal(self, query, value): """ Filter data with an equal (``=``) condition.