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


Python Configurator.add_view方法代碼示例

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


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

示例1: app

# 需要導入模塊: from repoze.bfg.configuration import Configurator [as 別名]
# 或者: from repoze.bfg.configuration.Configurator import add_view [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

示例2: RemoteUserAuthenticationPolicy

# 需要導入模塊: from repoze.bfg.configuration import Configurator [as 別名]
# 或者: from repoze.bfg.configuration.Configurator import add_view [as 別名]
if __name__ == "__main__":
    # Configure the BFG application

    ## Set up security policies, root object, etc.
    authentication_policy = RemoteUserAuthenticationPolicy()
    authorization_policy = ACLAuthorizationPolicy()
    config = Configurator(
        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)
開發者ID:repoze,項目名稱:repoze.who,代碼行數:33,代碼來源:example.py

示例3: Configurator

# 需要導入模塊: from repoze.bfg.configuration import Configurator [as 別名]
# 或者: from repoze.bfg.configuration.Configurator import add_view [as 別名]
if __name__ == '__main__':
    # Configure the BFG application

    ## Set up security policies, root object, etc.
    authentication_policy=RemoteUserAuthenticationPolicy()
    authorization_policy=ACLAuthorizationPolicy()
    config = Configurator(
                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))
開發者ID:andreypopp,項目名稱:repoze.who,代碼行數:33,代碼來源:example.py


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