Skip to content

Commit

Permalink
Push a test request context at the start of paster commands
Browse files Browse the repository at this point in the history
This is in order to avoid Flask RuntimeErrors when trying to generate
URLs without a request context being present.
  • Loading branch information
amercader committed Aug 17, 2017
1 parent 845d8a2 commit 33f11ce
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions ckan/lib/cli.py
Expand Up @@ -28,6 +28,7 @@
import ckan.include.rcssmin as rcssmin
import ckan.plugins as p
from ckan.common import config
from ckan.tests.helpers import _get_test_app


#NB No CKAN imports are allowed until after the config file is loaded.
Expand Down Expand Up @@ -224,6 +225,11 @@ def load_config(config, load_site_user=True):
from ckan.config.environment import load_environment
load_environment(conf.global_conf, conf.local_conf)

flask_app = _get_test_app().flask_app
flask_context = flask_app.test_request_context()

flask_context.push()

registry = Registry()
registry.prepare()
import pylons
Expand Down

0 comments on commit 33f11ce

Please sign in to comment.