refactor: bind hot_reload event via EventDispatcher, add on_hot_reload to PricingProgram
This commit is contained in:
parent
71329af722
commit
7b9d3d2ba0
BIN
pricing/__pycache__/init.cpython-310.pyc
Normal file
BIN
pricing/__pycache__/init.cpython-310.pyc
Normal file
Binary file not shown.
BIN
pricing/__pycache__/pricing.cpython-310.pyc
Normal file
BIN
pricing/__pycache__/pricing.cpython-310.pyc
Normal file
Binary file not shown.
@ -35,6 +35,9 @@ def load_pricing():
|
||||
env.load_pricing_data = PricingProgram.load_pricing_data
|
||||
env.get_pricing_program = PricingProgram.get_pricing_program
|
||||
env.test_pricing = test_pricing
|
||||
# Bind hot_reload event — staticmethod, ref safe (stored on class)
|
||||
if hasattr(env, 'event_dispatcher'):
|
||||
env.event_dispatcher.bind('hot_reload', PricingProgram.on_hot_reload)
|
||||
dbpools = DBPools()
|
||||
dbname = env.get_module_dbname('pricing')
|
||||
if dbname:
|
||||
|
||||
@ -186,6 +186,11 @@ def data_mapping(ns, name, v):
|
||||
class PricingProgram:
|
||||
pricing_data = {}
|
||||
|
||||
@staticmethod
|
||||
def on_hot_reload(data=None):
|
||||
"""Event handler for hot_reload event. Clears pricing cache."""
|
||||
PricingProgram.pricing_data.clear()
|
||||
|
||||
@staticmethod
|
||||
async def get_pricing_program(ppid):
|
||||
env = ServerEnv()
|
||||
|
||||
@ -1,7 +1,7 @@
|
||||
{
|
||||
"widgettype": "VBox",
|
||||
"options": {
|
||||
"cheight": 40,
|
||||
"css": "filler", "height": "100%",
|
||||
"width": "100%"
|
||||
},
|
||||
"subwidgets": [
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user