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


Python request.route_request_iface函数代码示例

本文整理汇总了Python中pyramid.request.route_request_iface函数的典型用法代码示例。如果您正苦于以下问题:Python route_request_iface函数的具体用法?Python route_request_iface怎么用?Python route_request_iface使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


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

示例1: register_route_request_iface

 def register_route_request_iface():
     request_iface = self.registry.queryUtility(IRouteRequest, name=name)
     if request_iface is None:
         if use_global_views:
             bases = (IRequest,)
         else:
             bases = ()
         request_iface = route_request_iface(name, bases)
         self.registry.registerUtility(
             request_iface, IRouteRequest, name=name)
开发者ID:XiaonuoGantan,项目名称:pyramid,代码行数:10,代码来源:routes.py

示例2: register_route_impl

def register_route_impl(cfg, name, pattern, factory,
                        predicates, pregenerator, use_global_views):
    request_iface = cfg.registry.queryUtility(IRouteRequest, name=name)
    if request_iface is None:
        if use_global_views:
            bases = (IRequest,)
        else:
            bases = ()
        request_iface = route_request_iface(name, bases)
        cfg.registry.registerUtility(request_iface, IRouteRequest, name=name)

    mapper = cfg.registry.queryUtility(IRoutesMapper)
    if mapper is None:
        mapper = RoutesMapper()
        cfg.registry.registerUtility(mapper, IRoutesMapper)

    return mapper.connect(name, pattern, factory, predicates=predicates,
                          pregenerator=pregenerator, static=False)
开发者ID:WouterVH,项目名称:ptah,代码行数:18,代码来源:route.py

示例3: _registerRouteRequest

 def _registerRouteRequest(self, name):
     from pyramid.interfaces import IRouteRequest
     from pyramid.request import route_request_iface
     iface = route_request_iface(name)
     self.registry.registerUtility(iface, IRouteRequest, name=name)
     return iface
开发者ID:RyoAbe,项目名称:pyramid,代码行数:6,代码来源:test_router.py

示例4: _callFUT

 def _callFUT(self, name):
     from pyramid.request import route_request_iface
     return route_request_iface(name)
开发者ID:deshank,项目名称:pyramid,代码行数:3,代码来源:test_request.py

示例5: add_route


#.........这里部分代码省略.........
          This argument can also be spelled as ``permission``.

        view_renderer

          .. warning:: Deprecated as of :app:`Pyramid` 1.1.

          This is either a single string term (e.g. ``json``) or a
          string implying a path or :term:`asset specification`
          (e.g. ``templates/views.pt``).  If the renderer value is a
          single term (does not contain a dot ``.``), the specified
          term will be used to look up a renderer implementation, and
          that renderer implementation will be used to construct a
          response from the view return value.  If the renderer term
          contains a dot (``.``), the specified term will be treated
          as a path, and the filename extension of the last element in
          the path will be used to look up the renderer
          implementation, which will be passed the full path.  The
          renderer implementation will be used to construct a response
          from the view return value.  See
          :ref:`views_which_use_a_renderer` for more information.

          If the ``view`` argument is not provided, this argument has
          no effect.

          This argument can also be spelled as ``renderer``.

        view_attr

          .. warning:: Deprecated as of :app:`Pyramid` 1.1.

          The view machinery defaults to using the ``__call__`` method
          of the view callable (or the function itself, if the view
          callable is a function) to obtain a response dictionary.
          The ``attr`` value allows you to vary the method attribute
          used to obtain the response.  For example, if your view was
          a class, and the class has a method named ``index`` and you
          wanted to use this method instead of the class' ``__call__``
          method to return the response, you'd say ``attr="index"`` in
          the view configuration for the view.  This is
          most useful when the view definition is a class.

          If the ``view`` argument is not provided, this argument has no
          effect.

        """
        # these are route predicates; if they do not match, the next route
        # in the routelist will be tried
        ignored, predicates, ignored = make_predicates(
            xhr=xhr,
            request_method=request_method,
            path_info=path_info,
            request_param=request_param,
            header=header,
            accept=accept,
            traverse=traverse,
            custom=custom_predicates
            )

        request_iface = self.registry.queryUtility(IRouteRequest, name=name)
        if request_iface is None:
            if use_global_views:
                bases = (IRequest,)
            else:
                bases = ()
            request_iface = route_request_iface(name, bases)
            self.registry.registerUtility(
                request_iface, IRouteRequest, name=name)
            deferred_views = getattr(self.registry, 'deferred_route_views', {})
            view_info = deferred_views.pop(name, ())
            for info in view_info:
                self.add_view(**info)

        # deprecated adding views from add_route
        if any([view, view_context, view_permission, view_renderer,
                view_for, for_, permission, renderer, view_attr]):
            self._add_view_from_route(
                route_name=name,
                view=view,
                permission=view_permission or permission,
                context=view_context or view_for or for_,
                renderer=view_renderer or renderer,
                attr=view_attr,
            )

        mapper = self.get_routes_mapper()

        factory = self.maybe_dotted(factory)
        if pattern is None:
            pattern = path
        if pattern is None:
            raise ConfigurationError('"pattern" argument may not be None')

        if self.route_prefix:
            pattern = self.route_prefix.rstrip('/') + '/' + pattern.lstrip('/')

        discriminator = ('route', name)
        self.action(discriminator, None)

        return mapper.connect(name, pattern, factory, predicates=predicates,
                              pregenerator=pregenerator, static=static)
开发者ID:DeanHodgkinson,项目名称:pyramid,代码行数:101,代码来源:routes.py

示例6: route

def route(_context,
          name,
          pattern=None,
          view=None,
          view_for=None,
          permission=None,
          factory=None,
          for_=None,
          header=None,
          xhr=False,
          accept=None,
          path_info=None,
          request_method=None,
          request_param=None,
          custom_predicates=(),
          view_permission=None,
          view_attr=None,
          renderer=None,
          view_renderer=None,
          view_context=None,
          traverse=None,
          use_global_views=False,
          path=None):
    """ Handle ``route`` ZCML directives
    """
    # the strange ordering of the request kw args above is for b/w
    # compatibility purposes.

    # these are route predicates; if they do not match, the next route
    # in the routelist will be tried
    reg = get_current_registry()

    if view_context is None:
        view_context = view_for or for_

    view_permission = view_permission or permission
    view_renderer = view_renderer or renderer
    if view_renderer and '.' in view_renderer:
        view_renderer = path_spec(_context, view_renderer)

    if pattern is None:
        pattern = path

    if pattern is None:
        raise ConfigurationError('route directive must include a "pattern"')

    def register():
        config = Configurator(reg, package=_context.package)
        config.add_route(
            name,
            pattern,
            factory=factory,
            header=header,
            xhr=xhr,
            accept=accept,
            path_info=path_info,
            request_method=request_method,
            request_param=request_param,
            custom_predicates=custom_predicates,
            view=view,
            view_context=view_context,
            view_permission=view_permission,
            view_renderer=view_renderer,
            view_attr=view_attr,
            use_global_views=use_global_views,
            traverse=traverse,
            _info=_context.info
            )

    discriminator = ['route', name, xhr, request_method, path_info,
                     request_param, header, accept]
    discriminator.extend(sorted(custom_predicates))
    discriminator = tuple(discriminator)
        
    _context.action(
        discriminator=discriminator,
        callable = register,
        )

    if view:
        request_iface = reg.queryUtility(IRouteRequest, name=name)
        if request_iface is None:
            request_iface = route_request_iface(name)
            reg.registerUtility(request_iface, IRouteRequest, name=name)
        _context.action(
            discriminator = (
                'view', view_context, '', None, IView, name, view_attr),
            )
开发者ID:markramm,项目名称:pyramid,代码行数:88,代码来源:zcml.py


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