コード例 #1
0
    def __init__(self, conf=None):
        self.config = load_config(conf)

        # package_update needs a translator defined i.e. _()
        from paste.registry import Registry
        import pylons
        registry = Registry()
        registry.prepare()
        registry.register(pylons.translator, MockTranslator())

        self.app = make_app(self.config.global_conf, **self.config.local_conf)
コード例 #2
0
ファイル: ckan_setup.py プロジェクト: mikkoi/ckan
def pytest_sessionstart(session):
    """Initialize CKAN environment.
    """
    conf = load_config(session.config.option.ckan_ini)
    # Set this internal test request context with the configured environment so
    # it can be used when calling url_for from the cli.
    global _tests_test_request_context

    app = make_app(conf.global_conf, **conf.local_conf)
    flask_app = app.apps['flask_app']._wsgi_app
    _tests_test_request_context = flask_app.test_request_context()
コード例 #3
0
ファイル: ckan_setup.py プロジェクト: tino097/ckan
def pytest_sessionstart(session):
    """Initialize CKAN environment.
    """
    conf = load_config(session.config.option.ckan_ini)
    # Set this internal test request context with the configured environment so
    # it can be used when calling url_for from the cli.
    global _tests_test_request_context

    app = make_app(conf)
    try:
        flask_app = app.apps['flask_app']._wsgi_app
    except AttributeError:
        flask_app = app._wsgi_app
    _tests_test_request_context = flask_app.test_request_context()

    # Create the snapshot of the initial configuration
    global _config
    _config = config.copy()
コード例 #4
0
ファイル: cli.py プロジェクト: starsinmypockets/ckan
 def __init__(self, conf=None):
     self.config = load_config(conf)
     self.app = make_app(self.config.global_conf, **self.config.local_conf)
コード例 #5
0
 def __init__(self, conf=None):
     # Don't import `load_config` by itself, rather call it using
     # module so that it can be patched during tests
     self.config = ckan_cli.load_config(conf)
     self.app = make_app(self.config.global_conf, **self.config.local_conf)
コード例 #6
0
 def __init__(self, conf: Optional[str] = None):
     # Don't import `load_config` by itself, rather call it using
     # module so that it can be patched during tests
     self.config = ckan_cli.load_config(conf)
     self.app = make_app(self.config)
コード例 #7
0
if __name__ == u'__main__':
    parser = argparse.ArgumentParser(usage=__doc__)
    parser.add_argument(u'-c', u'--config', help=u'CKAN config file (.ini)')
    parser.add_argument(u'--delete',
                        choices=[u'yes', u'no'],
                        help=u'Delete activity detail')
    parser.add_argument(u'--dataset',
                        help=u'just migrate this particular '
                        u'dataset - specify its name')
    args = parser.parse_args()
    assert args.config, u'You must supply a --config'
    print(u'Loading config')
    try:
        from ckan.cli import load_config
        from ckan.config.middleware import make_app
        make_app(load_config(args.config))
    except ImportError:
        # for CKAN 2.6 and earlier
        def load_config(config):
            from ckan.lib.cli import CkanCommand
            cmd = CkanCommand(name=None)

            class Options(object):
                pass

            cmd.options = Options()
            cmd.options.config = config
            cmd._load_config()
            return

        load_config(args.config)
コード例 #8
0
ファイル: cli.py プロジェクト: ckan/ckan
 def __init__(self, conf=None):
     self.config = load_config(conf)
     self.app = make_app(self.config.global_conf, **self.config.local_conf)