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:
parent
6352a6dc9a
commit
fe4c3d4942
|
@ -436,15 +436,18 @@ class VendorCatalogView(FileBatchMasterView):
|
|||
|
||||
def configure_remove_settings(self):
|
||||
super(VendorCatalogView, self).configure_remove_settings()
|
||||
model = self.model
|
||||
app = self.get_rattail_app()
|
||||
|
||||
names = [
|
||||
'rattail.vendors.supported_catalog_parsers',
|
||||
'tailbone.batch.vendorcatalog.supported_parsers', # deprecated
|
||||
]
|
||||
|
||||
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)
|
||||
|
||||
|
||||
# TODO: deprecate / remove this
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
################################################################################
|
||||
#
|
||||
# Rattail -- Retail Software Framework
|
||||
# Copyright © 2010-2021 Lance Edgar
|
||||
# Copyright © 2010-2022 Lance Edgar
|
||||
#
|
||||
# This file is part of Rattail.
|
||||
#
|
||||
|
@ -576,13 +576,19 @@ cd {prefix}
|
|||
return settings
|
||||
|
||||
def configure_remove_settings(self):
|
||||
app = self.get_rattail_app()
|
||||
model = self.model
|
||||
self.Session.query(model.Setting)\
|
||||
.filter(sa.or_(
|
||||
model.Setting.name.like('rattail.importing.%.handler'),
|
||||
model.Setting.name.like('rattail.importing.%.cmd'),
|
||||
model.Setting.name.like('rattail.importing.%.runas')))\
|
||||
.delete(synchronize_session=False)
|
||||
session = self.Session()
|
||||
|
||||
to_delete = session.query(model.Setting)\
|
||||
.filter(sa.or_(
|
||||
model.Setting.name.like('rattail.importing.%.handler'),
|
||||
model.Setting.name.like('rattail.importing.%.cmd'),
|
||||
model.Setting.name.like('rattail.importing.%.runas')))\
|
||||
.all()
|
||||
|
||||
for setting in to_delete:
|
||||
app.delete_setting(session, setting)
|
||||
|
||||
@classmethod
|
||||
def defaults(cls, config):
|
||||
|
|
|
@ -4482,6 +4482,7 @@ class MasterView(View):
|
|||
|
||||
def configure_remove_settings(self, simple_settings=None,
|
||||
input_file_templates=True):
|
||||
app = self.get_rattail_app()
|
||||
model = self.model
|
||||
names = []
|
||||
|
||||
|
@ -4500,20 +4501,21 @@ class MasterView(View):
|
|||
])
|
||||
|
||||
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_save_settings(self, settings):
|
||||
model = self.model
|
||||
# nb. we do not use self.Session b/c that may not point to the
|
||||
# Rattail DB for the subclass
|
||||
app = self.get_rattail_app()
|
||||
|
||||
# nb. using thread-local session here; we do not use
|
||||
# self.Session b/c it may not point to Rattail
|
||||
session = Session()
|
||||
for setting in settings:
|
||||
session.add(model.Setting(name=setting['name'],
|
||||
value=setting['value']))
|
||||
app.save_setting(session, setting['name'], setting['value'],
|
||||
force_create=True)
|
||||
|
||||
##############################
|
||||
# Pyramid View Config
|
||||
|
|
|
@ -417,16 +417,18 @@ class TransactionView(MasterView):
|
|||
|
||||
def configure_remove_settings(self):
|
||||
super(TransactionView, self).configure_remove_settings()
|
||||
app = self.get_rattail_app()
|
||||
|
||||
model = self.model
|
||||
names = [
|
||||
'trainwreck.db.hide',
|
||||
'tailbone.engines.trainwreck.hidden', # deprecated
|
||||
]
|
||||
# nb. we do not use self.Session b/c that points to trainwreck
|
||||
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)
|
||||
|
||||
@classmethod
|
||||
def defaults(cls, config):
|
||||
|
|
13
tailbone/views/vendors/core.py
vendored
13
tailbone/views/vendors/core.py
vendored
|
@ -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()
|
||||
|
|
Loading…
Reference in a new issue