diff --git a/src/wuttaweb/app.py b/src/wuttaweb/app.py index 845b41f..88318b4 100644 --- a/src/wuttaweb/app.py +++ b/src/wuttaweb/app.py @@ -61,7 +61,7 @@ class WebAppProvider(AppProvider): return self.web_handler -def make_wutta_config(settings): +def make_wutta_config(settings, config_maker=None, **kwargs): """ Make a WuttaConfig object from the given settings. @@ -93,8 +93,9 @@ def make_wutta_config(settings): "section of config to the path of your " "config file. Lame, but necessary.") - # make config per usual, add to settings - wutta_config = make_config(path) + # make config, add to settings + config_maker = config_maker or make_config + wutta_config = config_maker(path, **kwargs) settings['wutta_config'] = wutta_config # configure database sessions diff --git a/src/wuttaweb/forms/schema.py b/src/wuttaweb/forms/schema.py index a3a464b..4402fde 100644 --- a/src/wuttaweb/forms/schema.py +++ b/src/wuttaweb/forms/schema.py @@ -258,7 +258,12 @@ class PersonRef(ObjectRef): This is a subclass of :class:`ObjectRef`. """ - model_class = Person + + @property + def model_class(self): + """ """ + model = self.app.model + return model.Person def sort_query(self, query): """ """ diff --git a/src/wuttaweb/forms/widgets.py b/src/wuttaweb/forms/widgets.py index 6c77fe0..837b6f1 100644 --- a/src/wuttaweb/forms/widgets.py +++ b/src/wuttaweb/forms/widgets.py @@ -223,7 +223,7 @@ class UserRefsWidget(WuttaCheckboxChoiceWidget): users = [] if cstruct: for uuid in cstruct: - user = self.session.query(model.User).get(uuid) + user = self.session.get(model.User, uuid) if user: users.append(dict([(key, getattr(user, key)) for key in columns + ['uuid']])) diff --git a/src/wuttaweb/grids/base.py b/src/wuttaweb/grids/base.py index 5d5984f..0f2c812 100644 --- a/src/wuttaweb/grids/base.py +++ b/src/wuttaweb/grids/base.py @@ -1047,7 +1047,13 @@ class Grid: filters = filters or {} if self.model_class: - for key in self.get_model_columns(): + # TODO: i tried using self.get_model_columns() here but in + # many cases that will be too aggressive. however it is + # often the case that the *grid* columns are a subset of + # the unerlying *table* columns. so until a better way + # is found, we choose "too few" instead of "too many" + # filters here. surely must improve it at some point. + for key in self.columns: if key in filters: continue prop = getattr(self.model_class, key, None) diff --git a/src/wuttaweb/views/people.py b/src/wuttaweb/views/people.py index a19df57..78cf931 100644 --- a/src/wuttaweb/views/people.py +++ b/src/wuttaweb/views/people.py @@ -123,6 +123,12 @@ class PersonView(MasterView): @classmethod def defaults(cls, config): """ """ + + # nb. Person may come from custom model + wutta_config = config.registry.settings['wutta_config'] + app = wutta_config.get_app() + cls.model_class = app.model.Person + cls._defaults(config) cls._people_defaults(config) diff --git a/src/wuttaweb/views/settings.py b/src/wuttaweb/views/settings.py index a20e1f6..aa28416 100644 --- a/src/wuttaweb/views/settings.py +++ b/src/wuttaweb/views/settings.py @@ -51,6 +51,7 @@ class AppInfoView(MasterView): model_name = 'AppInfo' model_title_plural = "App Info" route_prefix = 'appinfo' + filterable = False sort_on_backend = False sort_defaults = 'name' paginated = False diff --git a/src/wuttaweb/views/users.py b/src/wuttaweb/views/users.py index 91ed2e0..5e28a26 100644 --- a/src/wuttaweb/views/users.py +++ b/src/wuttaweb/views/users.py @@ -207,6 +207,17 @@ class UserView(MasterView): role = session.get(model.Role, uuid) user.roles.remove(role) + @classmethod + def defaults(cls, config): + """ """ + + # nb. User may come from custom model + wutta_config = config.registry.settings['wutta_config'] + app = wutta_config.get_app() + cls.model_class = app.model.User + + cls._defaults(config) + def defaults(config, **kwargs): base = globals()