feat: allow app db to be rattail-native instead of wutta-native
not sure if that's even a good idea, but it sort of works.. more improvements would be needed, just saving the progress for now
This commit is contained in:
parent
43ad0ae1c1
commit
1804e74d13
|
@ -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
|
||||
|
|
|
@ -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):
|
||||
""" """
|
||||
|
|
|
@ -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']]))
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -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)
|
||||
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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()
|
||||
|
|
Loading…
Reference in a new issue