当前位置: 首页>>代码示例>>Python>>正文


Python Configurator.add_permission方法代码示例

本文整理汇总了Python中pyramid.config.Configurator.add_permission方法的典型用法代码示例。如果您正苦于以下问题:Python Configurator.add_permission方法的具体用法?Python Configurator.add_permission怎么用?Python Configurator.add_permission使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在pyramid.config.Configurator的用法示例。


在下文中一共展示了Configurator.add_permission方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: main

# 需要导入模块: from pyramid.config import Configurator [as 别名]
# 或者: from pyramid.config.Configurator import add_permission [as 别名]
def main(global_config, **settings):
    """ This function returns a Pyramid WSGI application.
    """
    engine = engine_from_config(settings, 'sqlalchemy.')
    DBSession.configure(bind = engine)
    Base.metadata.bind = engine

    authn_policy = AuthTktAuthenticationPolicy('sosecret', callback = groupfinder, hashalg = 'sha512')
    authz_policy = ACLAuthorizationPolicy()

    config = Configurator(settings = settings)    

    config.set_authentication_policy(authn_policy)
    config.set_authorization_policy(authz_policy)

    config.include('pyramid_jinja2')
    config.include('pyramid_chameleon')
    config.include('pyramid_sqlalchemy')
    config.include('ps_alchemy')
    
    config.add_static_view('static', 'static')
    config.add_permission(PYRAMID_SACRUD_HOME)


    config.add_route('home', '/')
    config.add_route('login', '/login')
    config.add_route('logout', '/logout')

    config.include('pyramid_sacrud', route_prefix = "admin")
    settings = config.registry.settings
    settings['pyramid_sacrud.models'] = (('DataBase', [Company, Member, Order]),
                                        ('Site', [Event]))
    
    config.scan()
    return config.make_wsgi_app()
开发者ID:FominaMasha,项目名称:Hello-site,代码行数:37,代码来源:__init__.py

示例2: main

# 需要导入模块: from pyramid.config import Configurator [as 别名]
# 或者: from pyramid.config.Configurator import add_permission [as 别名]
def main(global_config, **settings):
    config = Configurator(settings=settings, root_factory=Blog.root_factory)
    config.include('substanced')
    config.add_permission('view')
    config.add_static_view('static', 'static', cache_max_age=86400)
    config.scan()
    return config.make_wsgi_app()
开发者ID:tseaver,项目名称:substanced,代码行数:9,代码来源:__init__.py

示例3: main

# 需要导入模块: from pyramid.config import Configurator [as 别名]
# 或者: from pyramid.config.Configurator import add_permission [as 别名]
def main(global_config, **settings):
    """ This function returns a Pyramid WSGI application.
    """
    config = Configurator(settings=settings, root_factory=root_factory)
    config.include('substanced')
    config.include('sdexternaledit')
    config.add_permission('view')
    config.add_static_view('static', 'static', cache_max_age=86400)
    config.add_static_view('assets', 'static/theme', cache_max_age=86400)
    secret = settings['substanced.secret']
    # NB: we use the AuthTktAuthenticationPolicy rather than the session
    # authentication policy because using the session policy can cause static
    # resources to be uncacheable.  In particular, if you use the
    # UnencryptedBlahBlahBlah session factory, and anything asks for the
    # authenticated or unauthenticated user from the policy, the session needs
    # to be reserialized because that factory works by resetting the cookie on
    # every access to set the last-accessed value.  In practice, pyramid_tm
    # asks for the unauthenticated user, so every static resource will have a
    # set-cookie header in it, making them uncacheable.  This could also be
    # solved by using a different session factory (e.g. pyramid_redis_sessions)
    # which does not reserialize the cookie on every access.
    authn_policy = AuthTktAuthenticationPolicy(secret, callback=groupfinder)
    config.set_authentication_policy(authn_policy)
    config.scan()
    return config.make_wsgi_app()
开发者ID:Pylons,项目名称:sdnet_buildout,代码行数:27,代码来源:__init__.py

示例4: main

# 需要导入模块: from pyramid.config import Configurator [as 别名]
# 或者: from pyramid.config.Configurator import add_permission [as 别名]
def main(global_config, **settings):
    # we dont want these values in our settings.ini
    mail_settings = {
        'mail.host':os.environ.get('YSS_MAIL_HOST', 'localhost'),
        'mail.port':os.environ.get('YSS_MAIL_PORT', '25'),
        'mail.username':os.environ.get('YSS_MAIL_USERNAME', None),
        'mail.password':os.environ.get('YSS_MAIL_PASSWORD', None),
        }
    settings.update(mail_settings)
    settings['redis.sessions.secret'] = os.environ.get(
        'YSS_REDIS_SESSIONS_SECRET', 'seekr1t')
    settings['substanced.secret'] = os.environ.get(
        'YSS_SUBSTANCED_SECRET', 'seekri1')
    mimetypes.add_type('application/font-woff', '.woff')
    secret = settings['substanced.secret']
    authn_policy = YSSAuthenticationPolicy(secret)
    sentry_dsn = os.environ.get('YSS_SENTRY_DSN')
    if sentry_dsn:
        sentry_sdk.init(dsn=sentry_dsn, integrations=[PyramidIntegration()])
    config = Configurator(
        settings=settings,
        root_factory=root_factory,
        authentication_policy=authn_policy,
    )
    session_factory = session_factory_from_settings(settings)
    config.set_session_factory(session_factory)

    config.include('substanced')
    config.include('pyramid_layout')
    config.include('velruse.providers.twitter')
    config.include('velruse.providers.google_oauth2')
    config.include('.root')
    config.include('.evolve')
    config.include('.catalog')
    config.include('.songs')
    config.include('.recordings')
    config.add_twitter_login(
        consumer_key=os.environ['YSS_TWITTER_LOGIN_CONSUMER_KEY'],
        consumer_secret=os.environ['YSS_TWITTER_LOGIN_CONSUMER_SECRET'],
    )
    config.add_google_oauth2_login(
        consumer_key=os.environ['YSS_GOOGLE_LOGIN_CONSUMER_KEY'],
        consumer_secret=os.environ['YSS_GOOGLE_LOGIN_CONSUMER_SECRET'],
        )
    config.add_static_view('static', 'yss.root.views:static')
    config.add_permission('yss.indexed')

    config.add_request_method(
        authentication_type,
        'authentication_type',
        reify=True
    )

    config.scan()
    return config.make_wsgi_app()
开发者ID:notaliens,项目名称:youshouldsing,代码行数:57,代码来源:__init__.py

示例5: main

# 需要导入模块: from pyramid.config import Configurator [as 别名]
# 或者: from pyramid.config.Configurator import add_permission [as 别名]
def main(global_config, **settings):
    """ This function returns a Pyramid WSGI application.
    """
    engine = engine_from_config(settings, 'sqlalchemy.')
    DBSession.configure(bind=engine)
    Base.metadata.bind = engine
    config = Configurator(
        settings=settings,
    )

    config.set_authentication_policy(
        authentication.AuthTktAuthenticationPolicy(
            config.get_settings().get('mediapublic.authentication_secret',
                                      'changeme'),
            callback=auth.associate_groups,
            hashalg='sha512',
        )
    )
    config.set_authorization_policy('mediapublic.auth.authz_policy')
    config.add_permission('get')
    config.add_permission('create')
    config.add_permission('update')
    config.add_permission('delete')

    config.include('cornice')
    config.scan('mediapublic.auth')
    config.scan('mediapublic.views')

    config.include('velruse.providers.twitter')

    return config.make_wsgi_app()
开发者ID:imwm,项目名称:mediapublic,代码行数:33,代码来源:__init__.py

示例6: main

# 需要导入模块: from pyramid.config import Configurator [as 别名]
# 或者: from pyramid.config.Configurator import add_permission [as 别名]
def main(global_config, **settings):
    """ This function returns a Pyramid WSGI application.
    """
    engine = engine_from_config(settings, 'sqlalchemy.')
    DBSession.configure(bind=engine)
    Base.metadata.bind = engine
    config = Configurator(
        settings=settings,
    )

    config.set_authentication_policy(
        authentication.AuthTktAuthenticationPolicy(
            config.get_settings().get('mediapublic.authentication_secret',
                                      'changeme'),
            callback=auth.associate_groups,
            hashalg='sha512',
        )
    )
    config.set_authorization_policy('mediapublic.auth.authz_policy')
    config.add_permission('get')
    config.add_permission('create')
    config.add_permission('update')
    config.add_permission('delete')

    config.include('cornice')
    config.scan('mediapublic.auth')
    config.scan('mediapublic.views')

    config.include('velruse.providers.twitter')

    config.add_view(mp_exc.handle_exceptions, context=Exception,
                    permission=security.NO_PERMISSION_REQUIRED)
    # TODO(ryansb): replace default 40(3|4) with JSON errors
    config.add_view(hooks.handle_exceptions,
                    context=httpexceptions.HTTPNotFound,
                    permission=security.NO_PERMISSION_REQUIRED)
    config.add_view(hooks.handle_exceptions,
                    context=httpexceptions.HTTPForbidden,
                    permission=security.NO_PERMISSION_REQUIRED)

    return config.make_wsgi_app()
开发者ID:nkkl,项目名称:mediapublic,代码行数:43,代码来源:__init__.py

示例7: _add_sdi_request_extensions

# 需要导入模块: from pyramid.config import Configurator [as 别名]
# 或者: from pyramid.config.Configurator import add_permission [as 别名]
def _add_sdi_request_extensions(config: Configurator):
    config.add_request_method(sdiapi, reify=True)
    config.add_permission('sdi.edit-properties')  # used by sheet machinery
    config.set_request_property(lambda r: r.user.locale, name='_LOCALE_')
开发者ID:Janaba,项目名称:adhocracy3,代码行数:6,代码来源:__init__.py


注:本文中的pyramid.config.Configurator.add_permission方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。