本文整理汇总了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()
示例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)
示例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))