在config File中有對應以下配置,用於啓動對應WSGI應用web
[app:app_name] paste.app_factory = yourproject.web:app_factory
app_factory會返回一個application的callable object, 此cb接受WSGI標準的兩個參數:app
class application(): def __init__(self): pass def __call__(self,environ, start_response): start_response("200 OK",[("Content-type", "text/plain")]) return ["Paste Deploy LAB",] envrion # 環境信息 start_response # 回調
在paste.deploy 中配置 filter, 可讓WSGI應用在調用前被hook,先調用filter的對象.工具
filter:authtoken paste.filter_factory = keystoneclient.middleware.auth_token:filter_factory
filter_factory與app_factory 同樣,接收配置參數,並返回一個 callable object, 此cb 會在每次調用 WSGI app時候調用,keystone也就是在這裏對API的認證作了hook.code
class Filter(): def __init__(self,app): self.app = app pass def __call__(self,environ,start_response): print "filter hook here." return self.app(environ,start_response)