Skip to content

Commit 1022957

Browse files
feat: sync keyvalue helpers
1 parent eaae918 commit 1022957

1 file changed

Lines changed: 23 additions & 0 deletions

File tree

pythoncms/app.py

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,8 @@
2323
from shopyo.api.debug import is_yo_debug
2424
from shopyo.api.file import trycopy
2525

26+
import sqlalchemy
27+
2628

2729
base_path = os.path.dirname(os.path.abspath(__file__))
2830
sys.path.insert(0, base_path)
@@ -37,6 +39,7 @@
3739
from shopyo_admin import MyAdminIndexView
3840
from shopyo_admin import DefaultModelView
3941
from modules.box__default.keyvalue.models import KeyValue
42+
from modules.box__default.keyvalue.helpers import set_value
4043
from init import db
4144

4245

@@ -64,6 +67,7 @@ def create_app(config_name="development"):
6467
load_blueprints(app, config_name, global_template_variables, global_configs)
6568
setup_theme_paths(app)
6669
inject_global_vars(app, global_template_variables)
70+
sync_keyvalue_envvar(app)
6771
return app
6872

6973

@@ -276,3 +280,22 @@ def get_setting(env_var):
276280
base_context.update(global_template_variables)
277281

278282
return base_context
283+
284+
285+
def sync_keyvalue_envvar(app):
286+
with app.app_context():
287+
try:
288+
set_value(
289+
'ACTIVE_FRONT_THEME',os.environ.get('ACTIVE_FRONT_THEME', 'editorial')
290+
)
291+
set_value(
292+
'ACTIVE_BACK_THEME',os.environ.get('ACTIVE_BACK_THEME', 'sneat')
293+
)
294+
set_value(
295+
'SITE_INFO',os.environ.get('SITE_INFO', 'Site Info')
296+
)
297+
set_value(
298+
'SITE_DESCRIPTION',os.environ.get('SITE_DESCRIPTION', 'Site Description')
299+
)
300+
except sqlalchemy.exc.OperationalError: # on shopyo initialise command
301+
pass

0 commit comments

Comments
 (0)