From 1c45472fe5aaa76e8b3a9dc39fc92709f4c31de6 Mon Sep 17 00:00:00 2001 From: Lance Edgar Date: Mon, 19 Sep 2016 16:34:12 -0500 Subject: [PATCH] Tweak how a grid filter factory is determined Don't inspect anything if a factory is provided by caller. --- tailbone/newgrids/alchemy.py | 33 +++++++++++++++++---------------- 1 file changed, 17 insertions(+), 16 deletions(-) diff --git a/tailbone/newgrids/alchemy.py b/tailbone/newgrids/alchemy.py index 6ae25a63..a195b92a 100644 --- a/tailbone/newgrids/alchemy.py +++ b/tailbone/newgrids/alchemy.py @@ -93,22 +93,23 @@ class AlchemyGrid(Grid): """ Make a filter suitable for use with the given column. """ - factory = filters.AlchemyGridFilter - if isinstance(column.type, sa.String): - factory = filters.AlchemyStringFilter - elif isinstance(column.type, sa.Numeric): - factory = filters.AlchemyNumericFilter - elif isinstance(column.type, sa.Integer): - factory = filters.AlchemyNumericFilter - elif isinstance(column.type, sa.Boolean): - factory = filters.AlchemyBooleanFilter - elif isinstance(column.type, sa.Date): - factory = filters.AlchemyDateFilter - elif isinstance(column.type, sa.DateTime): - factory = filters.AlchemyDateTimeFilter - elif isinstance(column.type, GPCType): - factory = filters.AlchemyGPCFilter - factory = kwargs.pop('factory', factory) + factory = kwargs.pop('factory', None) + if not factory: + factory = filters.AlchemyGridFilter + if isinstance(column.type, sa.String): + factory = filters.AlchemyStringFilter + elif isinstance(column.type, sa.Numeric): + factory = filters.AlchemyNumericFilter + elif isinstance(column.type, sa.Integer): + factory = filters.AlchemyNumericFilter + elif isinstance(column.type, sa.Boolean): + factory = filters.AlchemyBooleanFilter + elif isinstance(column.type, sa.Date): + factory = filters.AlchemyDateFilter + elif isinstance(column.type, sa.DateTime): + factory = filters.AlchemyDateTimeFilter + elif isinstance(column.type, GPCType): + factory = filters.AlchemyGPCFilter return factory(key, column=column, config=self.request.rattail_config, **kwargs) def iter_filters(self):