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


Python Configurator.make_wsgi_app方法代碼示例

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


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

示例1: main

# 需要導入模塊: from repoze.bfg.configuration import Configurator [as 別名]
# 或者: from repoze.bfg.configuration.Configurator import make_wsgi_app [as 別名]
def main(global_config, **settings):
    """ This function returns a WSGI application.
    
    It is usually called by the PasteDeploy framework during 
    ``paster serve``.
    """
    from repoze.bfg.authentication import AuthTktAuthenticationPolicy
    from checking.authorization import RouteAuthorizationPolicy
    from checking.authentication import verifyUser

    if not settings.get("sqlalchemy.url"):
        raise ValueError("No 'sqlalchemy.url' value in application configuration.")
    config = Configurator(settings=settings,
            authentication_policy=AuthTktAuthenticationPolicy("secret",
                callback=verifyUser,
                timeout=30*60, max_age=30*60,
                reissue_time=20*60),
            authorization_policy=RouteAuthorizationPolicy())
    config.hook_zca()
    config.begin()
    setupSqlalchemy(settings)
    setupRoutes(config)
    setupChameleon(config)
    setupi18n(config)
    config.end()

    app = config.make_wsgi_app()
    app = TM(app)

    return app
開發者ID:wichert,項目名稱:checking,代碼行數:32,代碼來源:run.py

示例2: app

# 需要導入模塊: from repoze.bfg.configuration import Configurator [as 別名]
# 或者: from repoze.bfg.configuration.Configurator import make_wsgi_app [as 別名]
def app(global_config, **settings):
    """ This function returns a WSGI application.
    
    It is usually called by the PasteDeploy framework during 
    ``paster serve``.
    """
    names = ('src_path', 'store_url', 'cache_url', 'max_entries', 'database', 'content_dir')
    values = []
    for name in names:
        val = settings.get(name)
        if val is None: 
            raise ValueError("No ’%s’ value in application configuration." % name) 
        values.append(val)
        
    src_path, store_url, cache_url, max_entries, database, content_dir = values
    
    zcml_file = settings.get('configure_zcml', 'configure.zcml')
    config = Configurator(settings=settings, root_factory=ContentRoot(content_dir))
    # use local component registry
    config.hook_zca()
    config.begin()
    config.load_zcml(zcml_file)
    
    register_source(src_path)
    register_store(store_url, cache_url, max_entries=max_entries)
    register_catalog(database)
    config.end()
    
    return config.make_wsgi_app()
開發者ID:vilos,項目名稱:rstlibrary,代碼行數:31,代碼來源:run.py

示例3: app

# 需要導入模塊: from repoze.bfg.configuration import Configurator [as 別名]
# 或者: from repoze.bfg.configuration.Configurator import make_wsgi_app [as 別名]
def app(global_config, **settings):
    """ This function returns a WSGI application.
    
    It is usually called by the PasteDeploy framework during 
    ``paster serve``.
    """
    zcml_file = settings.get('configure_zcml', 'configure.zcml')
    db_string = settings.get('db_string')
    if db_string is None:
        raise ValueError("No 'db_string' value in application configuration.")
    initialize_sql(db_string)
    config = Configurator(root_factory=get_root, settings=settings)
    config.begin()
    config.load_zcml(zcml_file)
    config.end()
    # Ugly hack to configure the MapperExtension with the settings.
    removal_extension.path = settings.get('upload_directory')
    
    scheduler = Scheduler()
    # Send out queued mails
    from eportfolio.utilities.mail_delivery import trigger_queued_delivery
    scheduler.add_interval_job(trigger_queued_delivery, seconds=30)
    scheduler.start()
    
    return config.make_wsgi_app()
開發者ID:FvD,項目名稱:cobal.eportfolio,代碼行數:27,代碼來源:run.py

示例4: app

# 需要導入模塊: from repoze.bfg.configuration import Configurator [as 別名]
# 或者: from repoze.bfg.configuration.Configurator import make_wsgi_app [as 別名]
def app(global_config, **settings):
    """ This function returns a WSGI application.
    
    It is usually called by the PasteDeploy framework during 
    ``paster serve``.
    """
    zcml_file = settings.get('configure_zcml', 'configure.zcml')
    root = Root(settings.get('amqp_host', 'localhost'),
                settings.get('amqp_exchange', EXCHANGE))
    config = Configurator(root_factory=lambda request: root, settings=settings)
    config.begin()
    config.load_zcml(zcml_file)
    config.end()
    if settings.get('debug', None):
        return DebuggedApplication(config.make_wsgi_app(), True)
    else:
        return config.make_wsgi_app()
開發者ID:boothead,項目名稱:multivisor,代碼行數:19,代碼來源:run.py

示例5: app

# 需要導入模塊: from repoze.bfg.configuration import Configurator [as 別名]
# 或者: from repoze.bfg.configuration.Configurator import make_wsgi_app [as 別名]
def app(global_config, **settings):
    """ This function returns a WSGI application.
    """
    zcml_file = settings.get('configure_zcml', 'configure.zcml')
    config = Configurator(root_factory=get_root, settings=settings)
    config.begin()
    config.load_zcml(zcml_file)
    config.end()
    return config.make_wsgi_app()
開發者ID:bluedynamics,項目名稱:bda.bfg.ugm,代碼行數:11,代碼來源:run.py

示例6: maintenance

# 需要導入模塊: from repoze.bfg.configuration import Configurator [as 別名]
# 或者: from repoze.bfg.configuration.Configurator import make_wsgi_app [as 別名]
def maintenance(global_config, **local_conf):
    config = Configurator()
    config.begin()
    config.add_static_view('static', 'karl.views:static')
    config.add_route(name='maintenance',
                    path='/*url',
                    view=dummy_view,
                    view_renderer='down_for_maintenance.pt')
    config.end()
    return config.make_wsgi_app()
開發者ID:cguardia,項目名稱:karl,代碼行數:12,代碼來源:maintenance.py

示例7: app

# 需要導入模塊: from repoze.bfg.configuration import Configurator [as 別名]
# 或者: from repoze.bfg.configuration.Configurator import make_wsgi_app [as 別名]
def app(global_config, **settings):
    """ This function returns a WSGI application.
    
    It is usually called by the PasteDeploy framework during 
    ``paster serve``.
    """
    config = Configurator()
    config.begin()
    config.add_view(home, renderer="templates/home.pt")
    config.add_view(expense, name='expense', renderer='templates/expense.pt')
    config.end()
    return config.make_wsgi_app()
開發者ID:shentonfreude,項目名稱:fare,代碼行數:14,代碼來源:run.py

示例8: app

# 需要導入模塊: from repoze.bfg.configuration import Configurator [as 別名]
# 或者: from repoze.bfg.configuration.Configurator import make_wsgi_app [as 別名]
def app(global_config, **settings):
    """ This function returns a WSGI application.

    It is usually called by the PasteDeploy framework during
    ``paster serve``.
    """
    zodb_uri = settings.get('zodb_uri')
    zcml_file = settings.get('configure_zcml', 'configure.zcml')
    if zodb_uri is None:
        raise ValueError("No 'zodb_uri' in application configuration.")

    finder = PersistentApplicationFinder(zodb_uri, appmaker)
    def get_root(request):
        return finder(request.environ)
    config = Configurator(root_factory=get_root, settings=settings)
    config.begin()
    config.load_zcml(zcml_file)
    config.end()
    return config.make_wsgi_app()
開發者ID:shentonfreude,項目名稱:DubCore,代碼行數:21,代碼來源:run.py

示例9: mailin_monitor_view

# 需要導入模塊: from repoze.bfg.configuration import Configurator [as 別名]
# 或者: from repoze.bfg.configuration.Configurator import make_wsgi_app [as 別名]
def mailin_monitor_view(context, request):
    """
    Dispatches to a subapp from repoze.mailin.monitor.  I know this looks kind
    of horrible, but this is the best way I know how to mount another object
    graph onto the root object graph in BFG 1.2.  BFG 1.3 will theoretically
    allow SCRIPT_NAME/PATH_INFO rewriting for routes of the form
    '/some/path/*traverse', making it easier to do this with just a route,
    rather than actually constituting a whole new bfg app just to serve this
    subtree.
    """
    global _mailin_monitor_app
    if _mailin_monitor_app is None:
        # Keep imports local in hopes that this can be removed when BFG 1.3
        # comes out.
        from repoze.bfg.authorization import ACLAuthorizationPolicy
        from repoze.bfg.configuration import Configurator
        from karl.models.mailin_monitor import KarlMailInMonitor
        from karl.security.policy import get_groups
        from repoze.bfg.authentication import RepozeWho1AuthenticationPolicy

        authentication_policy = RepozeWho1AuthenticationPolicy(
            callback=get_groups
        )
        authorization_policy = ACLAuthorizationPolicy()
        config = Configurator(root_factory=KarlMailInMonitor(),
                              authentication_policy=authentication_policy,
                              authorization_policy=authorization_policy)
        config.begin()
        config.load_zcml('repoze.mailin.monitor:configure.zcml')
        config.end()
        _mailin_monitor_app = config.make_wsgi_app()

    # Dispatch to subapp
    import webob
    sub_environ = request.environ.copy()
    sub_environ['SCRIPT_NAME'] = '/%s/%s' % (model_path(context),
                                            request.view_name)
    sub_environ['PATH_INFO'] = '/' + '/'.join(request.subpath)
    sub_request = webob.Request(sub_environ)
    return sub_request.get_response(_mailin_monitor_app)
開發者ID:boothead,項目名稱:karl,代碼行數:42,代碼來源:admin.py

示例10: app

# 需要導入模塊: from repoze.bfg.configuration import Configurator [as 別名]
# 或者: from repoze.bfg.configuration.Configurator import make_wsgi_app [as 別名]
def app(global_config, **settings):
    """ This function returns a repoze.bfg.router.Router object.
    
    It is usually called by the PasteDeploy framework during ``paster serve``.
    """
    db_string = settings.get('db_string')
    if db_string is None:
        raise ValueError("No 'db_string' value in application configuration.")
    initialize_sql(db_string)
    
    # Scheduler to copy recurring invoices
    s = Scheduler()
    # Check every 5 minutes for recurring invoices
    s.add_interval_task(copy_recurring, 300)
    s.start_scheduler()
    
    config = Configurator(root_factory=RootFactory, settings=settings)
    config.begin()
    zcml_file = settings.get('configure_zcml', 'configure.zcml')
    config.load_zcml(zcml_file)
    config.end()
    return config.make_wsgi_app()
開發者ID:seantis,項目名稱:seantisinvoice,代碼行數:24,代碼來源:run.py

示例11: wsgi_app

# 需要導入模塊: from repoze.bfg.configuration import Configurator [as 別名]
# 或者: from repoze.bfg.configuration.Configurator import make_wsgi_app [as 別名]
def wsgi_app(**settings):
  config = Configurator(root_factory=get_root, settings=settings)
  config.load_zcml('configure.zcml')
  return config.make_wsgi_app()
開發者ID:topiaruss,項目名稱:bfg-gae-logger,代碼行數:6,代碼來源:run.py

示例12: cleartext_check

# 需要導入模塊: from repoze.bfg.configuration import Configurator [as 別名]
# 或者: from repoze.bfg.configuration.Configurator import make_wsgi_app [as 別名]
        root_factory=get_root,
        default_permission="view",
        authentication_policy=authentication_policy,
        authorization_policy=authorization_policy,
    )
    config.begin()

    ## Configure views
    config.add_view(unprotected)
    config.add_view(protected, "protected.html", permission="view_protected")
    config.add_view(login, "login.html")
    config.add_view(logout, "logout.html")
    config.end()

    ## Create the app object.
    app = config.make_wsgi_app()

    # Configure the repoze.who middleware:

    ## fake .htpasswd authentication source
    io = StringIO()
    for name, password in [("admin", "admin"), ("user", "user")]:
        io.write("%s:%s\n" % (name, password))
    io.seek(0)

    def cleartext_check(password, hashed):
        return password == hashed

    htpasswd = HTPasswdPlugin(io, cleartext_check)

    ## other plugins
開發者ID:repoze,項目名稱:repoze.who,代碼行數:33,代碼來源:example.py


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