zoukankan      html  css  js  c++  java
  • WSGI学习系列Paste

    Paste has been under development for a while, and has lots of code in it.

    The code is largely decoupled except for some core functions shared by many parts of the code.

    Those core functions are largely replaced in WebOb, and replaced with better implementations.

    The future of these pieces is to split them into independent packages, and refactor the internal Paste dependencies to rely instead on WebOb.

     

    paste.httpserver

    # Use paste httpserver
    from paste import httpserver
    httpserver.serve(application, host='127.0.0.1', port=8000)

     

    paste.deploy

    murano-paste.ini is as follows.

    [pipeline:murano]
    pipeline = versionnegotiation faultwrap authtoken context rootapp
    
    [filter:context]
    paste.filter_factory = murano.api.middleware.context:ContextMiddleware.factory
    
    #For more information see Auth-Token Middleware with Username and Password
    #http://docs.openstack.org/developer/keystone/configuringservices.html
    [filter:authtoken]
    paste.filter_factory = keystonemiddleware.auth_token:filter_factory
    
    [composite:rootapp]
    use = egg:Paste#urlmap
    /: apiversions
    /v1: apiv1app
    
    [app:apiversions]
    paste.app_factory = murano.api.versions:create_resource
    
    [app:apiv1app]
    paste.app_factory = murano.api.v1.router:API.factory
    
    [filter:versionnegotiation]
    paste.filter_factory = murano.api.middleware.version_negotiation:VersionNegotiationFilter.factory
    
    [filter:faultwrap]
    paste.filter_factory = murano.api.middleware.fault:FaultWrapper.factory

    (1) pipeline

    [pipeline:murano]

    pipeline = versionnegotiation faultwrap authtoken context rootapp

    pipeline is used when you need apply a number of filters.

    It takes one configuration key pipeline (plus any global configuration overrides you want).

    pipeline is a list of filters ended by an application.

    These filters are defined by the ini file.

    rootapp is a Murano application.

    (2) filter_factory

    Filters are callables that take a WSGI application as the only argument, and return a “filtered” version of that application.

    [filter:authtoken]

    paste.filter_factory = keystonemiddleware.auth_token:filter_factory

    For example, authtoken filter is implemented by keystonemiddleware.auth_token:filter_factory function.

    Before visiting the Murano Application interface, filter_factory function will call the keystone client to check the user or tenant authorization.

    (3) composite

    [composite:rootapp]

    use = egg:Paste#urlmap

    /: apiversions

    /v1: apiv1app

    The default site directory is implemented by apiversions app.

    The /v1 directory is implemented by apiv1app app.

    (4) app_factory

    [app:apiv1app]

    paste.app_factory = murano.api.v1.router:API.factory

    The application is the most common. You define one like:

    def app_factory(global_config, **local_conf):
        return wsgi_app

    The global_config is a dictionary, and local configuration is passed as keyword arguments.

    The function returns a WSGI application.

    apiv1app is implemented by murano.api.v1.router:API.factory function.

  • 相关阅读:
    除了Web和Node,JavaScript还能做什么
    从Hybrid到React-Native: JS在移动端的南征北战史
    当React开发者初次走进React-Native的世界
    【React-Native】React-Native组件样式合集
    【github】论怎么去写一个高大上的ReadMe
    https://github.com/sindresorhus/awesome-nodejs 清单
    https://github.com/akullpp/awesome-java 清单
    https://github.com/ChristosChristofidis/awesome-deep-learning 清单
    https://github.com/josephmisiti/awesome-machine-learning 清单
    SpringBoot 为什么能够自动的注入一些常用的Bean ?详细分析SpringBoot 自动配置的实现
  • 原文地址:https://www.cnblogs.com/edisonxiang/p/4753967.html
Copyright © 2011-2022 走看看