Skip to content

Commit 6fc3245

Browse files
committed
Instead of app.app_ctx.push()/pop(), create an AppContext(app) and use _cv_app.set(ctx)/_cv_app.reset(token)# Please enter the commit message for your changes. Lines starting
1 parent 51ba00e commit 6fc3245

1 file changed

Lines changed: 12 additions & 8 deletions

File tree

server/ansa/__init__.py

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
import logging
22
import superdesk
33

4+
from quart.ctx import AppContext
5+
from quart.globals import _cv_app
46
from superdesk.signals import item_publish
57
from superdesk.metadata.item import PUBLISH_STATES
68

@@ -65,14 +67,16 @@ def init_app(app):
6567
item_publish.connect(udpate_sign_off)
6668

6769
priority_to_profile_mapping = {}
68-
for key, val in app.config["PRIORITY_TO_PROFILE_MAPPING"].items():
69-
app.app_ctx.push()
70-
try:
71-
profile = app.data.find_one("content_types", req=None, label=val)
72-
finally:
73-
app.app_ctx.pop()
74-
if profile:
75-
priority_to_profile_mapping[key] = str(profile["_id"])
70+
if app.config.get("PRIORITY_TO_PROFILE_MAPPING"):
71+
for key, val in app.config["PRIORITY_TO_PROFILE_MAPPING"].items():
72+
ctx = AppContext(app)
73+
token = _cv_app.set(ctx)
74+
try:
75+
profile = app.data.find_one("content_types", req=None, label=val)
76+
finally:
77+
_cv_app.reset(token)
78+
if profile:
79+
priority_to_profile_mapping[key] = str(profile["_id"])
7680

7781
app.client_config.update(
7882
{

0 commit comments

Comments
 (0)