我们从Python开源项目中,提取了以下50个代码示例,用于说明如何使用pyramid.config.Configurator()。
def configuration(request): """Set up a Configurator instance. This Configurator instance sets up a pointer to the location of the database. It also includes the models from your app's model package. Finally it tears everything down, including the Postgres database. This configuration will persist for the entire duration of your PyTest run. """ settings = { 'sqlalchemy.url': TEST_DB} config = testing.setUp(settings=settings) config.include('pylistener.models') config.include('pylistener.routes') def teardown(): testing.tearDown() request.addfinalizer(teardown) return config
def create_app(_crypto=None, _kinesis=None, _raven=None, _stats=None): configure_logging() raven = create_raven(transport='gevent', _raven=_raven) try: config = Configurator(settings={}) config.add_tween('miracle.log.log_tween_factory', under=EXCVIEW) configure_api_views(config) configure_web_views(config) config.registry.crypto = create_crypto(_crypto=_crypto) config.registry.kinesis = create_kinesis(_kinesis=_kinesis) config.registry.raven = raven config.registry.stats = create_stats(_stats=_stats) wsgi_app = config.make_wsgi_app() except Exception: # pragma: no cover raven.captureException() raise return wsgi_app
def test_tween_overriden(): """ In case our tween is overriden by the user config we should not log rendering """ from ...test_tracer import get_dummy_tracer from ...util import override_global_tracer tracer = get_dummy_tracer() with override_global_tracer(tracer): config = Configurator(settings={'pyramid.tweens': 'pyramid.tweens.excview_tween_factory'}) trace_pyramid(config) def json(request): return {'a': 1} config.add_route('json', '/json') config.add_view(json, route_name='json', renderer='json') app = webtest.TestApp(config.make_wsgi_app()) app.get('/json', status=200) spans = tracer.writer.pop() assert not spans
def main(global_config, **settings): print for name in ENV_SETTINGS: settings[name] = get_config_environ(name) or settings.get(name) for name in REQUIRED_SETTINGS: if settings.get(name) is None: error = 'confiration entry for {} is missing'.format(name) logger.critical(error) raise ConfigurationError(error) config = Configurator(settings=settings) config.include("cornice") config.scan("edwiges.views") host = settings['edwiges.provider_host'] port = settings['edwiges.provider_port'] logger.info("Starting server", extra={'host': host, 'port': port}) return config.make_wsgi_app()
def main(global_config, **settings): """ This function returns a Pyramid WSGI application. """ engine = engine_from_config(settings, 'sqlalchemy.') DBSession.configure(bind=engine) Base.metadata.bind = engine config = Configurator(settings=settings) config.add_renderer('json', custom_json_renderer()) config.add_renderer('json2', custom_json_renderer2()) config.include('pyramid_jinja2') config.include('.models') config.include('.routes') config.scan() return config.make_wsgi_app()
def add_template_only_view(config: Configurator, pattern: str, name: str, template: str, view_args: t.Optional[dict]=None, route_args: t.Optional[dict]=None): """Adds a view which do not have a specific view function assgined. The view will render a template with the default template context. :param pattern: A path where the view is, e.g. ``/features`` :param name: View name for ``route_url()`` :param tempalte: A template to render :param view_args: kwargs passed to :py:meth:`pyramid.config.Configurator.add_view` :param route_args: kwargs passed to :py:meth:`pyramid.config.Configurator.add_view` """ def _default_view(request): return {} config.add_route(name, pattern) config.add_view(view=_default_view, route_name=name, renderer=template)
def add_static_view(self, name: str, path: str): """Include a path in static assets and configures cache busting for it. This does not only include the static resources in the routing, but sets the default cache busting policy for them in the :term:`production` environment. See :py:meth:`pyramid.config.Configurator.add_static_view` and :py:meth:`websauna.system.Initializer.add_cache_buster` """ # Default value is 0 cache_max_age = self.settings.get("websauna.cache_max_age_seconds") if cache_max_age: cache_max_age = int(cache_max_age) self.config.add_static_view(name, path, cache_max_age=cache_max_age) # If we have caching... we need cachebusters! if cache_max_age: self.config.add_cache_buster(path, CollectedStaticCacheBuster(name, path, self.settings)) self.views[name] = path
def setup_wsgi(): configurator = Configurator() configurator.include("pyramid_jinja2") configurator.add_jinja2_renderer('.html') configurator.add_jinja2_search_path('websauna.tests:templates/viewconfig', name='.html') configurator.add_route("parent_hello", "/parent_hello") configurator.add_route("child_hello", "/child_hello") from websauna.tests.viewconfig import testmodule configurator.set_root_factory(testmodule.Root) configurator.scan(testmodule) wsgi = TestApp(configurator.make_wsgi_app()) return wsgi
def main(global_config, **settings): """ This function returns a Pyramid WSGI application. """ config = Configurator(settings=settings) config.include('pyramid_jinja2') config.include('.models') config.include('.routes') config.scan() config.commit() config.add_request_method( lambda x: config.get_jinja2_environment(), 'jinja2_env', reify=True ) return config.make_wsgi_app()
def main(global_config, **settings): """Return a Pyramid WSGI application.""" if not settings.get('sqlalchemy.url'): try: settings['sqlalchemy.url'] = os.environ['MARS_DATABASE_URL'] except KeyError: print('Required MARS_DATABASE_URL not set in global os environ.') sys.exit() try: settings['nasa_api_key'] = os.environ['NASA_API_KEY'] except KeyError: print('Required NASA_API_KEY not set in global os environment.') sys.exit() engine = engine_from_config(settings, 'sqlalchemy.') DBSession.configure(bind=engine) Base.metadata.bind = engine config = Configurator(settings=settings) config.include('pyramid_jinja2') config.add_static_view('static', 'static', cache_max_age=3600) config.add_route('home', '/') config.add_route('rover', '/{rover_name}/{sol}') config.scan() return config.make_wsgi_app()
def main(global_config, **settings): """ This function returns a Pyramid WSGI application. """ set_cache_regions_from_settings(settings) session_factory = session_factory_from_settings(settings) engine = engine_from_config(settings, 'sqlalchemy.') mymodels.DBSession.configure(bind=engine) mymodels.Base.metadata.bind = engine config = Configurator(settings=settings) config.include('pyramid_chameleon') config.include('pyramid_jinja2') config.set_session_factory(session_factory) config.include('pyramid_beaker') config.add_static_view('static', 'static', cache_max_age=3600) config.add_route('home', '/') config.add_route('nearest', '/nearest') pyramid_jsonapi.create_jsonapi_using_magic_and_pixie_dust( config, mymodels, lambda view: mymodels.DBSession) config.scan() return config.make_wsgi_app()
def main(global_config, **settings): config = Configurator(settings=settings) config.add_subscriber(add_cors_headers_response_callback, NewRequest) config.add_settings({'MODELERLOCATION': settings['modelerlocation'] }) config.add_route('questionanalysis', '/questionanalysis/{question}') config.add_route('topicmatching', '/topicmatching/{domain}') config.add_route('datasetranking', '/datasetranking/{domain}/{analytic_type}/{interpretation}') config.add_route('vizranking', '/vizranking') # Knowledgemodel and domain models # config.add_route('getcorpus', '/getcorpus/{corpus}') # config.add_route('gettaxonomyfordomain', '/gettaxonomyfordomain/{domain}') # config.add_route('gettfidffordomainX', '/gettfidffordomain/{domain}/{corpus}') config.scan('.views') return config.make_wsgi_app()
def main(global_config, **settings): """This function returns a Pyramid WSGI application.""" settings['SOFTWARE_VERSION'] = __VERSION__ config = Configurator(settings=settings) # Addons config.include('pyramid_jinja2') # http://docs.pylonsproject.org/projects/pyramid-jinja2/en/latest/#adding-or-overriding-a-renderer config.add_jinja2_renderer('.html') config.include('cornice') # Views and routes config.add_static_view('static/app', 'static/app', cache_max_age=0) config.add_static_view('static/lib', 'static/lib', cache_max_age=60 * 24) config.add_route('index', '/') config.scan() return config.make_wsgi_app()
def configuration(request): """Set up a Configurator instance. This Configurator instance sets up a pointer to the location of the database. It also includes the models from the octojobs model package. Finally it tears everything down, including the in-memory database. This configuration will persist for the entire duration of your PyTest run. """ settings = { 'sqlalchemy.url': 'postgres:///test_jobs'} config = testing.setUp(settings=settings) config.include('octojobs.models') config.include('octojobs.routes') def teardown(): testing.tearDown() request.addfinalizer(teardown) return config
def get_app(overrides=None): settings = { 'odata_metadata': db.get_odata_metadata(), 'django_metadata': db.get_django_metadata(), 'cdms_client': api.CDMSRestApi() } if overrides is not None: settings.update(overrides) app_cfg = Configurator(root_factory=auth.Root, settings=settings) app_cfg.set_authentication_policy(auth.AuthenticationPolicy()) app_cfg.set_authorization_policy(ACLAuthorizationPolicy()) app_cfg.set_default_permission('access') app_cfg.add_route('create', '/create/{django_tablename}/') app_cfg.add_route('update', '/update/{django_tablename}/') app_cfg.add_route('get', '/get/{django_tablename}/{ident}/') app_cfg.scan('korben.bau.views') return app_cfg.make_wsgi_app()
def configuration(request): """Set up a Configurator instance. This Configurator instance sets up a pointer to the location of the database. It also includes the models from your app's model package. Finally it tears everything down, including the in-memory SQLite database. This configuration will persist for the entire duration of your PyTest run. """ config = testing.setUp(settings={ 'sqlalchemy.url': 'postgres://localhost:5432/test_expenses' }) config.include("expense_tracker.models") config.include("expense_tracker.routes") def teardown(): testing.tearDown() request.addfinalizer(teardown) return config
def main(global_config, **settings): """ Return a Pyramid WSGI application. """ settings['config_uri'] = global_config['__file__'] config = Configurator(registry=getGlobalSiteManager()) config.setup_registry(settings=settings) config.add_translation_dirs('assembl:locale/') def my_locale_negotiator(request): locale = default_locale_negotiator(request) available = settings['available_languages'].split() locale = locale if locale in available else None if not locale: locale = request.accept_language.best_match( available, settings.get('pyramid.default_locale_name', 'en')) request._LOCALE_ = locale return locale config.set_locale_negotiator(my_locale_negotiator) config.add_static_view('static', 'static', cache_max_age=3600) config.add_static_view('widget', 'widget', cache_max_age=3600) config.add_view(maintenance_message) config.add_notfound_view(maintenance_message) return config.make_wsgi_app()
def test_declarative_config(dummy_request): from snovault.interfaces import AUDITOR from pyramid.config import Configurator config = Configurator() config.include('snovault.config') config.include('snovault.auditor') config.include('.testing_auditor') config.commit() auditor = config.registry[AUDITOR] value = {'condition1': True} dummy_request._embed['/foo/@@embedded'] = value error, = auditor.audit(request=dummy_request, path='/foo/', types='TestingLinkSource') assert error['detail'] == 'Missing checker1' assert error['category'] == 'testchecker' assert error['level'] == 0 assert error['path'] == '/foo/'
def main(global_config, **settings): config = Configurator(settings=settings) config.add_renderer('jsonp', JSONP(param_name='callback', indent=None, separators=(',', ':'))) config.add_route('mapprint', '/print') config.scan() return config.make_wsgi_app()
def main(global_config, **settings): """ This function returns a Pyramid WSGI application. """ session_factory = session_factory_from_settings(settings) config = Configurator( root_factory=root_factory, session_factory=session_factory, settings=settings, ) config.add_static_view('static', 'static', cache_max_age=3600) config.include('ticketing.setup') config.include('ticketing.mainviews') config.include('ticketing.raven') config.include('ticketing.profile') config.include('ticketing.boxoffice') config.include('ticketing.queue') config.include('ticketing.manage', route_prefix="/admin") config.include('ticketing.checkin') config.add_renderer('api_renderer', 'ticketing.api.api_renderer.APIRenderer') config.include('ticketing.api') config.add_route("admin_catch","/admin") # Add authentication policies authentication_policy = AuthTktAuthenticationPolicy('ticketing', callback=checkGroups, hashalg='sha512') authorization_policy = ACLAuthorizationPolicy() config.set_authentication_policy(authentication_policy) config.set_authorization_policy(authorization_policy) config.set_default_permission("public") # Scan for views config.scan() return config.make_wsgi_app()
def main(global_config, **settings): """ This function returns a Pyramid WSGI application. """ secret = settings['corpus.secret'] session_factory = SignedCookieSessionFactory(secret) config = Configurator(settings=settings) config.set_session_factory(session_factory) config.include('pyramid_chameleon') config.add_static_view('static', 'static', cache_max_age=3600) config.add_route('home', '/') config.add_route('upload_csv', '/upload') config.add_route('corpus_view', '/view/{doc}/{corpus}/{page}') config.add_route('corpus_topics', '/topics/{doc}/{corpus}') config.add_route('delete_corpus', '/delete/{doc}/{corpus}') config.add_route('process_csv', '/process/{doc}/') config.add_route('corpus_classify', '/classify/{doc}/{corpus}') config.add_route('view_job', '/job-view/{doc}/{corpus}/job/{job}') config.add_route('demo', '/demo') config.add_request_method(corpus_cache, reify=True) config.include('eea.corpus.processing') config.scan() return config.make_wsgi_app()
def main(global_config, **settings): """This function returns a Pyramid WSGI application.""" config = Configurator(settings=settings) config.include('pyramid_chameleon') config.add_directive( 'add_cors_preflight_handler', add_cors_preflight_handler) config.add_route_predicate('cors_preflight', CorsPreflightPredicate) config.add_subscriber(add_cors_to_response, 'pyramid.events.NewResponse') config.add_route( 'cors-options-preflight', '/{catch_all:.*}', cors_preflight=True, ) config.add_view( cors_options_view, route_name='cors-options-preflight', permission=NO_PERMISSION_REQUIRED, ) config.add_renderer('prettyjson', JSON(indent=4, sort_keys=True)) config.add_static_view('static', 'static', cache_max_age=3600) config.add_route('home', '/') config.add_route('programs', '/playlist') config.add_route('program-type-list', '/program-type-list') config.add_route('program-type-news', '/program-type-news') config.add_route('playlist', '/playlist/{playlist_id}') config.add_route('playlist-per-type', '/type-playlist/{playlist_id}') config.add_route('radio', '/radio') config.add_route('radio-program-type-list', '/radio-program-type-list') config.add_route('radio-playlist-per-type', '/type-rplaylist/{playlist_id}') config.add_route('radio-stations', '/radio-stations') config.add_route('radio-station-program-list', '/radio-station-programs/{station_id}') config.add_route('radioplaylist', '/rplaylist/{playlist_id:[a-zA-Z0-9\.\-\/]+}') config.add_route('episode', '/episode/{episode_url:[a-zA-Z0-9\.\-\/]+}') config.scan() return config.make_wsgi_app()
def main(global_config, **settings): """ This function returns a Pyramid WSGI application. """ engine = engine_from_config(settings, 'sqlalchemy.') DBSession.configure(bind=engine) Base.metadata.bind = engine config = Configurator(settings=settings) config.include('pyramid_chameleon') config.add_static_view('static', 'static', cache_max_age=3600) config.add_route('home', '/') config.scan() return config.make_wsgi_app()
def main(global_config, **settings): if not global_config.get("testing"): # pragma: no cover DefaultStorage.init_db() config = Configurator(settings=settings) config.include("cornice") config.scan("ensign.api.resources") return config.make_wsgi_app()
def add_site_facebook_login(site, app): registry = get_current_registry() config = Configurator(registry=registry, autocommit=True) name = app.application_site_id add_facebook_login( config, consumer_key=getattr(app, 'consumer_key', ''), consumer_secret=getattr(app, 'consumer_secret', ''), scope=getattr(app, 'scop', ''), login_path='/login/'+name, callback_path='/login/'+name+'/callback', name=name)
def add_site_twitter_login(site, app): registry = get_current_registry() config = Configurator(registry=registry, autocommit=True) name = app.application_site_id add_twitter_login( config, consumer_key=getattr(app, 'consumer_key', ''), consumer_secret=getattr(app, 'consumer_secret', ''), login_path='/login/'+name, callback_path='/login/'+name+'/callback', name=name)
def add_site_google_login(site, app): registry = get_current_registry() config = Configurator(registry=registry, autocommit=True) name = app.application_site_id add_google_login( config, consumer_key=getattr(app, 'consumer_key', ''), consumer_secret=getattr(app, 'consumer_secret', ''), scope=getattr(app, 'scope', ''), login_path='/login/'+name, callback_path='/login/'+name+'/callback', name=name)
def main(global_config, **settings): """ This function returns a Pyramid WSGI application. """ config = Configurator(settings=settings) config.include('pyramid_chameleon') config.add_static_view('static', 'static', cache_max_age=3600) config.add_route('home', '/') config.scan() return config.make_wsgi_app()
def configure(self, settings): """ This initial settings of pyramid Configurator :param settings: :dict settings of Configurator :return: pyramid.config.Configurator """ if settings.get('environ') is None: environ = os.environ if settings is None: settings = {} if settings.get('env') is not None: for s in settings.get('env'): try: result = s(environ) except SettingError as e: log.warn(e) if result is not None: settings.update(result) if 'secret_key' not in settings: log.warn('No secret key provided: using transient key. Please ' 'configure the secret_key setting or the SECRET_KEY ' 'environment variable!') settings['secret_key'] = os.urandom(64) # Set up SQLAlchemy debug logging if 'debug_query' in settings: level = logging.INFO if settings['debug_query'] == 'trace': level = logging.DEBUG logging.getLogger('sqlalchemy.engine').setLevel(level) # set from config file settings.update( config_yaml(self.import_name, _yaml=self.__trafaret)) return Configurator(settings=settings)
def setUp(self): super(TestWebapp, self).setUp() self.stats1 = { 'status': 'done', 'chunks': { 'main': [ { 'name': 'main.js', 'path': '/static/main.js', }, ], }, } self.stats2 = { 'status': 'done', 'chunks': { 'libs': [ { 'name': 'libs.js', 'path': '/static/libs.js', }, ], }, } settings = { 'pyramid.includes': ['pyramid_jinja2', 'pyramid_webpack'], 'jinja2.extensions': ['pyramid_webpack.jinja2ext:WebpackExtension'], 'jinja2.directories': ['tests:templates/'], 'webpack.debug': True, 'webpack.stats_file': self._write('stats1.json', self.stats1), 'webpack.configs': ['other'], 'webpack.other.stats_file': self._write('stats2.json', self.stats2), } config = Configurator(settings=settings) config.add_route('bundle', '/bundle/{config}/{bundle}') config.add_view(_get_bundle, route_name='bundle', renderer='json') app = config.make_wsgi_app() self.app = webtest.TestApp(app)
def testapp(request): """Create an instance of webtests TestApp for testing routes. With the alchemy scaffold we need to add to our test application the setting for a database to be used for the models. We have to then set up the database by starting a database session. Finally we have to create all of the necessary tables that our app normally uses to function. The scope of the fixture is function-level, so every test will get a new test application. """ from webtest import TestApp from pyramid.config import Configurator def main(global_config, **settings): config = Configurator(settings=settings) config.include('pyramid_jinja2') config.include('.models') config.include('.routes') config.include('.security') config.scan() return config.make_wsgi_app() app = main({}, **{'sqlalchemy.url': TEST_DB}) testapp = TestApp(app) SessionFactory = app.registry["dbsession_factory"] engine = SessionFactory().bind Base.metadata.drop_all(engine) Base.metadata.create_all(bind=engine) return testapp
def main(global_config, **settings): """ This function returns a Pyramid WSGI application. """ if "sqlalchemy.url" not in settings: settings["sqlalchemy.url"] = os.environ["DATABASE_URL"] config = Configurator(settings=settings) config.include('pyramid_jinja2') config.include('.models') config.include('.routes') config.include('.security') config.scan() return config.make_wsgi_app()
def initiate(cls, **settings): """Initiate UnicamPI, if it's not already. :param settings: **dict, the settings transmitted to `Configurator` instance. :return: cls """ if cls.app is None: cls.config = Configurator(settings=settings) cls.config.include("cornice") # config.include("pyramid_swagger") cls._register_resources() def add_cors_headers_response_callback(event): def cors_headers(request, response): response.headers.update({ 'Access-Control-Allow-Origin': '*', 'Access-Control-Allow-Methods': 'POST,GET,DELETE,PUT,OPTIONS', 'Access-Control-Allow-Headers': 'Origin, Content-Type, Accept, Authorization', 'Access-Control-Allow-Credentials': 'true', 'Access-Control-Max-Age': '1728000', }) event.request.add_response_callback(cors_headers) cls.config.add_subscriber(add_cors_headers_response_callback, NewRequest) cls.app = cls.config.make_wsgi_app() return cls
def setUp(self): from tests.test_tracer import get_dummy_tracer self.tracer = get_dummy_tracer() settings = { 'datadog_trace_service': 'foobar', 'datadog_tracer': self.tracer } config = Configurator(settings=settings) self.rend = config.testing_add_renderer('template.pt') trace_pyramid(config) app = get_app(config) self.app = webtest.TestApp(app)
def test_include_conflicts(): """ Test that includes do not create conflicts """ from ...test_tracer import get_dummy_tracer from ...util import override_global_tracer tracer = get_dummy_tracer() with override_global_tracer(tracer): config = Configurator(settings={'pyramid.includes': 'tests.contrib.pyramid.test_pyramid'}) trace_pyramid(config) app = webtest.TestApp(config.make_wsgi_app()) app.get('/', status=404) spans = tracer.writer.pop() assert spans eq_(len(spans), 1)
def setUp(self): from tests.test_tracer import get_dummy_tracer self.tracer = get_dummy_tracer() ddtrace.tracer = self.tracer config = Configurator() self.rend = config.testing_add_renderer('template.pt') app = get_app(config) self.app = webtest.TestApp(app)
def setUp(self): from tests.test_tracer import get_dummy_tracer self.tracer = get_dummy_tracer() ddtrace.tracer = self.tracer config = Configurator(settings={'pyramid.tweens': 'pyramid.tweens.excview_tween_factory\n'}) self.rend = config.testing_add_renderer('template.pt') app = get_app(config) self.app = webtest.TestApp(app)
def test_include_conflicts(): """ Test that includes do not create conflicts """ from ...test_tracer import get_dummy_tracer from ...util import override_global_tracer tracer = get_dummy_tracer() with override_global_tracer(tracer): config = Configurator(settings={'pyramid.includes': 'tests.contrib.pyramid.test_pyramid_autopatch'}) app = webtest.TestApp(config.make_wsgi_app()) app.get('/', status=404) spans = tracer.writer.pop() assert spans eq_(len(spans), 1)
def test_app(request): """Instantiate a turing tweet app for testing.""" from webtest import TestApp from pyramid.config import Configurator def main(global_config, **settings): """Return a Pyramid WSGI application.""" settings['sqlalchemy.url'] = os.environ.get('DATABASE_URL_TESTING') config = Configurator(settings=settings) config.include('pyramid_jinja2') config.include('.models') config.include('.routes') config.scan() return config.make_wsgi_app() app = main({}) testapp = TestApp(app) session_factory = app.registry["dbsession_factory"] engine = session_factory().bind Base.metadata.create_all(bind=engine) def tearDown(): Base.metadata.drop_all(bind=engine) request.addfinalizer(tearDown) return testapp
def main(global_config, **settings): """ This function returns a Pyramid WSGI application.""" if os.environ.get('DATABASE_URL', ''): settings["sqlalchemy.url"] = os.environ["DATABASE_URL"] config = Configurator(settings=settings) config.include('pyramid_jinja2') config.include('.models') config.include('.routes') config.scan() return config.make_wsgi_app()
def testapp(settings): from pyramid.config import Configurator with Configurator(settings=settings) as config: config.include('ninjadog') config.add_route('home', '/') config.add_view( lambda request: {'title': 'title', 'subtitle': 'subtitle', 'content': 'This is a paragraph'}, route_name='home', renderer='./templates/child.pug', ) app = config.make_wsgi_app() yield _TestApp(app)
def _get_app_config(self, settings=None): config = Configurator(settings=self.get_app_settings(settings)) kinto.core.initialize(config, version='0.0.1') return config
def __init__(self, config:Configurator): self.config = config
def includeme(config: Configurator): """Entry point for Websauna main app to include this addon. In the Initializer of your app you should have: def include_addons(self): # ... self.config.include("websauna.blog") """ addon_init = AddonInitializer(config) addon_init.run()
def main(global_config, **settings): """ This function returns a Pyramid WSGI application. """ config = Configurator(settings=settings) init_logging(config) # runs first init_mode(config) init_includes(config) init_routing(config) init_db(config) init_smtp_mail(config) init_email_templates(config) return config.make_wsgi_app()
def setUp(self): self.config = MagicMock(spec=Configurator) self.router = ViewSetRouter(self.config)
def test_load_plugins(self, mock_includeme, mock_iter_entry_points): config = Configurator() group = 'openregistry.api.plugins' kwargs = {'plugins': ['api']} entry_point = mock.MagicMock() entry_point.name = 'api' mock_iter_entry_points.return_value = entry_point load_plugins(config, group, **kwargs) mock_includeme.assert_called_once_with(config)
def main(global_config, config=None, **settings): if not config: config = Configurator(settings=settings) config.add_settings({'project_name': 'webpush-channels'}) kinto.core.initialize(config, version=__version__, default_settings=DEFAULT_SETTINGS) config.scan("webpush_channels.views") app = config.make_wsgi_app() return kinto.core.install_middlewares(app, settings)
def main(_, **settings): """ This function returns a Pyramid WSGI application. """ config = Configurator(settings=settings) register_includes(config) register_json_renderer(config) register_routes(config) config.scan() return config.make_wsgi_app()