當前位置: 首頁>>代碼示例>>Python>>正文


Python pecan.make_app方法代碼示例

本文整理匯總了Python中pecan.make_app方法的典型用法代碼示例。如果您正苦於以下問題:Python pecan.make_app方法的具體用法?Python pecan.make_app怎麽用?Python pecan.make_app使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在pecan的用法示例。


在下文中一共展示了pecan.make_app方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: setup_app

# 需要導入模塊: import pecan [as 別名]
# 或者: from pecan import make_app [as 別名]
def setup_app(pecan_config=None, debug=False, argv=None):
    """Creates and returns a pecan wsgi app."""
    if argv is None:
        argv = sys.argv
    octavia_service.prepare_service(argv)
    cfg.CONF.log_opt_values(LOG, logging.DEBUG)

    _init_drivers()

    if not pecan_config:
        pecan_config = get_pecan_config()
    pecan_configuration.set_config(dict(pecan_config), overwrite=True)

    return pecan_make_app(
        pecan_config.app.root,
        wrap_app=_wrap_app,
        debug=debug,
        hooks=pecan_config.app.hooks,
        wsme=pecan_config.wsme
    ) 
開發者ID:openstack,項目名稱:octavia,代碼行數:22,代碼來源:app.py

示例2: setup_app

# 需要導入模塊: import pecan [as 別名]
# 或者: from pecan import make_app [as 別名]
def setup_app(pecan_config):
    config = dict(pecan_config)

    config['app']['debug'] = cfg.CONF['service:api'].pecan_debug

    pecan.configuration.set_config(config, overwrite=True)

    app = pecan.make_app(
        pecan_config.app.root,
        debug=getattr(pecan_config.app, 'debug', False),
        force_canonical=getattr(pecan_config.app, 'force_canonical', True),
        request_cls=patches.Request,
        guess_content_type_from_ext=False
    )

    return app 
開發者ID:openstack,項目名稱:designate,代碼行數:18,代碼來源:app.py

示例3: setup_app

# 需要導入模塊: import pecan [as 別名]
# 或者: from pecan import make_app [as 別名]
def setup_app(config=None):
    if not config:
        config = get_pecan_config()

    app_conf = dict(config.app)
    common_config.set_config_defaults()

    app = pecan.make_app(
        app_conf.pop('root'),
        logging=getattr(config, 'logging', {}),
        wrap_app=middleware.ParsableErrorMiddleware,
        guess_content_type_from_ext=False,
        **app_conf
    )

    return app 
開發者ID:openstack,項目名稱:magnum,代碼行數:18,代碼來源:app.py

示例4: setup_app

# 需要導入模塊: import pecan [as 別名]
# 或者: from pecan import make_app [as 別名]
def setup_app(root, conf=None):
    app_hooks = [hooks.ConfigHook(),
                 hooks.TranslationHook(),
                 hooks.GCHook(),
                 hooks.RPCHook(),
                 hooks.ContextHook(),
                 hooks.DBHook(),
                 hooks.CoordinatorHook()]

    app = pecan.make_app(
        root,
        hooks=app_hooks,
        guess_content_type_from_ext=False
    )

    return app 
開發者ID:openstack,項目名稱:vitrage,代碼行數:18,代碼來源:app.py

示例5: get_api_app

# 需要導入模塊: import pecan [as 別名]
# 或者: from pecan import make_app [as 別名]
def get_api_app():
    app_conf = get_pecan_config()
    storage_backend = storage.get_storage()

    app_hooks = [
        hooks.RPCHook(),
        hooks.StorageHook(storage_backend),
        hooks.ContextHook(),
    ]

    return pecan.make_app(
        app_conf.app.root,
        static_root=app_conf.app.static_root,
        template_path=app_conf.app.template_path,
        debug=CONF.api.pecan_debug,
        force_canonical=getattr(app_conf.app, 'force_canonical', True),
        hooks=app_hooks,
        guess_content_type_from_ext=False,
    ) 
開發者ID:openstack,項目名稱:cloudkitty,代碼行數:21,代碼來源:__init__.py

示例6: setup_app

# 需要導入模塊: import pecan [as 別名]
# 或者: from pecan import make_app [as 別名]
def setup_app(config=None):
    """Create a WSGI application object."""

    if not config:
        config = get_pecan_config()

    # Setup the hooks for WSGI Application(Like Middleware in Paste).
    #    EG. app_hooks = [hooks.DBHook()]
    app_hooks = []
    # Setup the config for WSGI Application.
    app_conf = dict(config.app)

    # Create and init the WSGI Application.
    app = pecan.make_app(
        app_conf.pop('root'),
        logging=getattr(config, 'logging', {}),
        hooks=app_hooks,
        **app_conf
    )
    return app 
開發者ID:JmilkFan,項目名稱:JmilkFan-s-Blog,代碼行數:22,代碼來源:wsgi_app.py

示例7: setUp

# 需要導入模塊: import pecan [as 別名]
# 或者: from pecan import make_app [as 別名]
def setUp(self):
        super(SecureControllerSharedPermissionsRegression, self).setUp()

        class Parent(object):
            @expose()
            def index(self):
                return 'hello'

        class UnsecuredChild(Parent):
            pass

        class SecureChild(Parent, SecureController):
            @classmethod
            def check_permissions(cls):
                return False

        class RootController(object):

            secured = SecureChild()
            unsecured = UnsecuredChild()

        self.app = TestApp(make_app(RootController())) 
開發者ID:pecan,項目名稱:pecan,代碼行數:24,代碼來源:test_secure.py

示例8: test_getall_with_trailing_slash

# 需要導入模塊: import pecan [as 別名]
# 或者: from pecan import make_app [as 別名]
def test_getall_with_trailing_slash(self):

        class ThingsController(RestController):

            data = ['zero', 'one', 'two', 'three']

            @expose('json')
            def get_all(self):
                return dict(items=self.data)

        class RootController(object):
            things = ThingsController()

        # create the app
        app = TestApp(make_app(RootController()))

        # test get_all
        r = app.get('/things/')
        assert r.status_int == 200
        assert r.body == b_(dumps(dict(items=ThingsController.data))) 
開發者ID:pecan,項目名稱:pecan,代碼行數:22,代碼來源:test_rest.py

示例9: test_post_with_kwargs_only

# 需要導入模塊: import pecan [as 別名]
# 或者: from pecan import make_app [as 別名]
def test_post_with_kwargs_only(self):

        class RootController(RestController):

            @expose()
            def get_all(self):
                return 'INDEX'

            @expose('json')
            def post(self, **kw):
                return kw

        # create the app
        app = TestApp(make_app(RootController()))

        r = app.get('/')
        assert r.status_int == 200
        assert r.body == b_('INDEX')

        kwargs = {'foo': 'bar', 'spam': 'eggs'}
        r = app.post('/', kwargs)
        assert r.status_int == 200
        assert r.namespace['foo'] == 'bar'
        assert r.namespace['spam'] == 'eggs' 
開發者ID:pecan,項目名稱:pecan,代碼行數:26,代碼來源:test_rest.py

示例10: test_nested_rest_with_default

# 需要導入模塊: import pecan [as 別名]
# 或者: from pecan import make_app [as 別名]
def test_nested_rest_with_default(self):

        class FooController(RestController):

            @expose()
            def _default(self, *remainder):
                return "DEFAULT %s" % remainder

        class RootController(RestController):
            foo = FooController()

        app = TestApp(make_app(RootController()))

        r = app.get('/foo/missing')
        assert r.status_int == 200
        assert r.body == b_("DEFAULT missing") 
開發者ID:pecan,項目名稱:pecan,代碼行數:18,代碼來源:test_rest.py

示例11: test_rest_with_non_utf_8_body

# 需要導入模塊: import pecan [as 別名]
# 或者: from pecan import make_app [as 別名]
def test_rest_with_non_utf_8_body(self):
        if PY3:
            # webob+PY3 doesn't suffer from this bug; the POST parsing in PY3
            # seems to more gracefully detect the bytestring
            return

        class FooController(RestController):

            @expose()
            def post(self):
                return "POST"

        class RootController(RestController):
            foo = FooController()

        app = TestApp(make_app(RootController()))

        data = struct.pack('255h', *range(0, 255))
        r = app.post('/foo/', data, expect_errors=True)
        assert r.status_int == 400 
開發者ID:pecan,項目名稱:pecan,代碼行數:22,代碼來源:test_rest.py

示例12: test_internal_redirect_with_after_hook

# 需要導入模塊: import pecan [as 別名]
# 或者: from pecan import make_app [as 別名]
def test_internal_redirect_with_after_hook(self):
        run_hook = []

        class RootController(object):
            @expose()
            def internal(self):
                redirect('/testing', internal=True)

            @expose()
            def testing(self):
                return 'it worked!'

        class SimpleHook(PecanHook):
            def after(self, state):
                run_hook.append('after')

        app = TestApp(make_app(RootController(), hooks=[SimpleHook()]))
        response = app.get('/internal')
        assert response.body == b_('it worked!')

        assert len(run_hook) == 1 
開發者ID:pecan,項目名稱:pecan,代碼行數:23,代碼來源:test_hooks.py

示例13: setup_app

# 需要導入模塊: import pecan [as 別名]
# 或者: from pecan import make_app [as 別名]
def setup_app(pecan_config=None, extra_hooks=None):
    if not pecan_config:
        pecan_config = get_pecan_config()

    app_hooks = [hooks.ConfigHook(),
                 hooks.ConductorAPIHook(),
                 hooks.ContextHook(pecan_config.app.acl_public_routes),
                 hooks.PublicUrlHook()]
    if extra_hooks:
        app_hooks.extend(extra_hooks)

    app_conf = dict(pecan_config.app)
    app = pecan.make_app(
        app_conf.pop('root'),
        force_canonical=getattr(pecan_config.app, 'force_canonical', True),
        hooks=app_hooks,
        wrap_app=middleware.ParsableErrorMiddleware,
        **app_conf
    )

    return app 
開發者ID:openstack,項目名稱:cyborg,代碼行數:23,代碼來源:app.py

示例14: _setup_app

# 需要導入模塊: import pecan [as 別名]
# 或者: from pecan import make_app [as 別名]
def _setup_app(root, conf, not_implemented_middleware):
    app = pecan.make_app(
        root,
        hooks=(GnocchiHook(conf),),
        guess_content_type_from_ext=False,
        custom_renderers={"json": JsonRenderer}
    )

    if not_implemented_middleware:
        app = webob.exc.HTTPExceptionMiddleware(NotImplementedMiddleware(app))

    return app 
開發者ID:gnocchixyz,項目名稱:gnocchi,代碼行數:14,代碼來源:app.py

示例15: setup_app

# 需要導入模塊: import pecan [as 別名]
# 或者: from pecan import make_app [as 別名]
def setup_app(config=None):
    if not config:
        config = get_pecan_config()

    app_conf = dict(config.app)
    common_config.set_config_defaults()

    app = pecan.make_app(
        app_conf.pop('root'),
        logging=getattr(config, 'logging', {}),
        wrap_app=middleware.ParsableErrorMiddleware,
        **app_conf
    )

    return app 
開發者ID:openstack,項目名稱:zun,代碼行數:17,代碼來源:app.py


注:本文中的pecan.make_app方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。