Make sure "configure" pages use AppHandler to save/delete settings

so that beaker config cache is invalidated, if in use
This commit is contained in:
Lance Edgar 2022-08-07 18:23:15 -05:00
parent 6352a6dc9a
commit fe4c3d4942
5 changed files with 45 additions and 33 deletions

View file

@ -202,8 +202,7 @@ class VendorView(MasterView):
def configure_remove_settings(self, **kwargs):
super(VendorView, self).configure_remove_settings(**kwargs)
model = self.model
app = self.get_rattail_app()
names = []
supported_vendor_settings = self.configure_get_supported_vendor_settings()
@ -211,11 +210,11 @@ class VendorView(MasterView):
names.append('rattail.vendor.{}'.format(setting['key']))
if names:
# nb. we do not use self.Session b/c that may not point to
# the Rattail DB for the subclass
Session().query(model.Setting)\
.filter(model.Setting.name.in_(names))\
.delete(synchronize_session=False)
# nb. using thread-local session here; we do not use
# self.Session b/c it may not point to Rattail
session = Session()
for name in names:
app.delete_setting(session, name)
def configure_get_supported_vendor_settings(self):
app = self.get_rattail_app()