当前位置: 首页>>代码示例>>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;未经允许,请勿转载。