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


Python Configurator.with_context方法代码示例

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


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

示例1: static

# 需要导入模块: from pyramid.config import Configurator [as 别名]
# 或者: from pyramid.config.Configurator import with_context [as 别名]
def static(_context, name, path, cache_max_age=3600,
           permission='__no_permission_required__'):
    """ Handle ``static`` ZCML directives
    """
    config = Configurator.with_context(_context)
    config.add_static_view(name, path, cache_max_age=cache_max_age,
                           permission=permission)
开发者ID:csenger,项目名称:pyramid,代码行数:9,代码来源:zcml.py

示例2: configure

# 需要导入模块: from pyramid.config import Configurator [as 别名]
# 或者: from pyramid.config.Configurator import with_context [as 别名]
    def configure(self):
        config = Configurator.with_context(self.context)

        for action in self():
            config.action(*action)

        return config
开发者ID:mmariani,项目名称:pyramid_skins,代码行数:9,代码来源:zcml.py

示例3: view

# 需要导入模块: from pyramid.config import Configurator [as 别名]
# 或者: from pyramid.config.Configurator import with_context [as 别名]
def view(
    _context,
    permission=None,
    for_=None,
    view=None,
    name="",
    request_type=None,
    route_name=None,
    request_method=None,
    request_param=None,
    containment=None,
    attr=None,
    renderer=None,
    wrapper=None,
    xhr=False,
    accept=None,
    header=None,
    path_info=None,
    traverse=None,
    custom_predicates=(),
    context=None,
    cacheable=True, # not used, here for b/w compat < 0.8
    ):

    context = context or for_
    config = Configurator.with_context(_context)
    config.add_view(
        permission=permission, context=context, view=view, name=name,
        request_type=request_type, route_name=route_name,
        request_method=request_method, request_param=request_param,
        containment=containment, attr=attr, renderer=renderer,
        wrapper=wrapper, xhr=xhr, accept=accept, header=header,
        path_info=path_info, custom_predicates=custom_predicates)
开发者ID:tamentis,项目名称:pyramid,代码行数:35,代码来源:zcml.py

示例4: subscriber

# 需要导入模块: from pyramid.config import Configurator [as 别名]
# 或者: from pyramid.config.Configurator import with_context [as 别名]
def subscriber(_context, for_=None, factory=None, handler=None, provides=None):
    if factory is None:
        if handler is None:
            raise TypeError("No factory or handler provided")
        if provides is not None:
            raise TypeError("Cannot use handler with provides")
        factory = handler
    else:
        if handler is not None:
            raise TypeError("Cannot use handler with factory")
        if provides is None:
            raise TypeError(
                "You must specify a provided interface when registering "
                "a factory")

    if for_ is None:
        for_ = getattr(factory, '__component_adapts__', None)
        if for_ is None:
            raise TypeError("No for attribute was provided and can't "
                            "determine what the factory (or handler) adapts.")

    for_ = tuple(for_)

    config = Configurator.with_context(_context)

    if handler is not None:
        config.add_subscriber(handler, for_)
    else:
        registry = _context.registry
        _context.action(
            discriminator = None,
            callable = registry.registerSubscriptionAdapter,
            args = (factory, for_, provides, None, _context.info),
            )
开发者ID:csenger,项目名称:pyramid,代码行数:36,代码来源:zcml.py

示例5: registerRoute

# 需要导入模块: from pyramid.config import Configurator [as 别名]
# 或者: from pyramid.config.Configurator import with_context [as 别名]
def registerRoute():
    cfg = Configurator.with_context(config.getContext())
    def getMNG(request):
        return umng
    cfg.add_route(
        'ploud.frontend', 'usermanagement/*traverse',
        factory=getMNG, use_global_views = True)
开发者ID:nerdfiles,项目名称:ploud-prod,代码行数:9,代码来源:usermng.py

示例6: repozewho1authenticationpolicy

# 需要导入模块: from pyramid.config import Configurator [as 别名]
# 或者: from pyramid.config.Configurator import with_context [as 别名]
def repozewho1authenticationpolicy(_context, identifier_name='auth_tkt',
                                   callback=None):
    policy = RepozeWho1AuthenticationPolicy(identifier_name=identifier_name,
                                            callback=callback)
    # authentication policies must be registered eagerly so they can
    # be found by the view registration machinery
    config = Configurator.with_context(_context)
    config._set_authentication_policy(policy)
开发者ID:csenger,项目名称:pyramid,代码行数:10,代码来源:zcml.py

示例7: remoteuserauthenticationpolicy

# 需要导入模块: from pyramid.config import Configurator [as 别名]
# 或者: from pyramid.config.Configurator import with_context [as 别名]
def remoteuserauthenticationpolicy(_context, environ_key='REMOTE_USER',
                                   callback=None):
    policy = RemoteUserAuthenticationPolicy(environ_key=environ_key,
                                            callback=callback)
    # authentication policies must be registered eagerly so they can
    # be found by the view registration machinery
    config = Configurator.with_context(_context)
    config._set_authentication_policy(policy)
开发者ID:csenger,项目名称:pyramid,代码行数:10,代码来源:zcml.py

示例8: notfound

# 需要导入模块: from pyramid.config import Configurator [as 别名]
# 或者: from pyramid.config.Configurator import with_context [as 别名]
def notfound(_context,
             view=None,
             attr=None,
             renderer=None,
             wrapper=None):

    config = Configurator.with_context(_context)
    config.set_notfound_view(view=view, attr=attr, renderer=renderer,
                             wrapper=wrapper)
开发者ID:csenger,项目名称:pyramid,代码行数:11,代码来源:zcml.py

示例9: forbidden

# 需要导入模块: from pyramid.config import Configurator [as 别名]
# 或者: from pyramid.config.Configurator import with_context [as 别名]
def forbidden(_context,
             view=None,
             attr=None,
             renderer=None,
             wrapper=None):

    config = Configurator.with_context(_context)
    config.set_forbidden_view(view=view, attr=attr, renderer=renderer,
                             wrapper=wrapper)
开发者ID:csenger,项目名称:pyramid,代码行数:11,代码来源:zcml.py

示例10: aclauthorizationpolicy

# 需要导入模块: from pyramid.config import Configurator [as 别名]
# 或者: from pyramid.config.Configurator import with_context [as 别名]
def aclauthorizationpolicy(_context):
    policy = ACLAuthorizationPolicy()
    # authorization policies must be registered eagerly so they can be
    # found by the view registration machinery
    config = Configurator.with_context(_context)
    if hasattr(config, 'set_authorization_policy'): # pragma: no cover
        # pyramid 1.2dev
        config.set_authorization_policy(policy)
    else: # pragma: no cover
        config._set_authorization_policy(policy)
开发者ID:jinty,项目名称:pyramid_zcml,代码行数:12,代码来源:__init__.py

示例11: repozewho2authenticationpolicy

# 需要导入模块: from pyramid.config import Configurator [as 别名]
# 或者: from pyramid.config.Configurator import with_context [as 别名]
def repozewho2authenticationpolicy(_context,
                                   config_file,
                                   identifier_name,
                                   callback=None):
    if callback is None:
        policy = WhoV2AuthenticationPolicy(config_file, identifier_name)
    else:
        policy = WhoV2AuthenticationPolicy(config_file, identifier_name,
                                           callback=callback)
    # authentication policies must be registered eagerly so they can
    # be found by the view registration machinery
    config = Configurator.with_context(_context)
    config._set_authentication_policy(policy)
开发者ID:virhilo,项目名称:pyramid_who,代码行数:15,代码来源:zcml.py

示例12: viewgroup

# 需要导入模块: from pyramid.config import Configurator [as 别名]
# 或者: from pyramid.config.Configurator import with_context [as 别名]
def viewgroup(_context,
              name="",
              viewnames=None,
              for_=None,
              context=None,
              ):

    if not viewnames:
        raise ConfigurationError('"viewnames" attribute was not specified')

    config = Configurator.with_context(_context)

    if not hasattr(config, 'add_viewgroup'):
        config.add_directive('add_viewgroup', add_viewgroup)

    context = context or for_

    config.add_viewgroup(name, viewnames, context=context)
开发者ID:lugensa,项目名称:pyramid_viewgroup,代码行数:20,代码来源:zcml.py

示例13: after

# 需要导入模块: from pyramid.config import Configurator [as 别名]
# 或者: from pyramid.config.Configurator import with_context [as 别名]
    def after(self):
        if getattr(self.context, 'forms', None) is not None:
            self.context.forms.append(self)
            return
        
        config = Configurator.with_context(self.context)
        display_action = FormAction(None)
        for action in [display_action] + self._actions:
            form_view = FormView(self.controller, action, self._actions,
                                 self.form_id, self.method)

            config.add_view(permission=self.permission,
                            for_=self.for_,
                            view=form_view,
                            name=self.name,
                            request_param=action.name,
                            route_name=self.route_name,
                            containment=self.containment,
                            renderer=self.renderer,
                            wrapper=self.wrapper)
开发者ID:davidblewett,项目名称:pyramid_formish,代码行数:22,代码来源:zcml.py

示例14: translationdir

# 需要导入模块: from pyramid.config import Configurator [as 别名]
# 或者: from pyramid.config.Configurator import with_context [as 别名]
def translationdir(_context, dir):
    path = path_spec(_context, dir)
    config = Configurator.with_context(_context)
    config.add_translation_dirs(path)
开发者ID:csenger,项目名称:pyramid,代码行数:6,代码来源:zcml.py

示例15: localenegotiator

# 需要导入模块: from pyramid.config import Configurator [as 别名]
# 或者: from pyramid.config.Configurator import with_context [as 别名]
def localenegotiator(_context, negotiator):
    config = Configurator.with_context(_context)
    config.set_locale_negotiator(negotiator)
开发者ID:csenger,项目名称:pyramid,代码行数:5,代码来源:zcml.py


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