Find a route in the router based on the specified view name.

        :param view_name: string of view name to search by
        :param kwargs: additional params, usually for static files
        :return: tuple containing (uri, Route)
489877
def find_route_by_view_name(self, view_name, name=None):
        
        if not view_name:
            return (None, None)

        if view_name == "static" or view_name.endswith(".static"):
            return self.routes_static_files.get(name, (None, None))

        return self.routes_names.get(view_name, (None, None))
989930
def view_attr(attr_name):
    

    def view_attr(value, context, **_params):
        setattr(context["view"], attr_name, value)
        return _attr()

    return view_attr
83903
def register_view(self, view, url_prefix=None):
        
        if url_prefix is None:
            if view.name is None:
                raise ValueError("EngineView has no name and path is not specified")
            url_prefix = view.name
        # bind entry points
        self.add_url_rule('/%s' % url_prefix, '%s_options' % url_prefix, view.options, methods=["GET"])
        self.add_url_rule('/%s' % url_prefix, '%s' % url_prefix, view.play, methods=["POST"])
        # url
        self.add_url_rule('/%s/options' % url_prefix, '%s_options_OLD' % url_prefix, view.options, methods=["GET"])
        self.add_url_rule('/%s/play' % url_prefix, '%s_OLD' % url_prefix, view.play, methods=["POST"])

        # manage short route
        for route in view._short_routes:
            self.add_url_rule(
                '/%s/%s' % (url_prefix, route),
                '%s_short_play' % url_prefix,
                view.short_play, methods=["GET"]
            )
903662
def find_template_path(name):
    
    global template_source_loaders
    if template_source_loaders is None:
        loaders = []
        for loader_name in settings.TEMPLATE_LOADERS:
            loader = find_template_loader(loader_name)
            if loader is not None:
                loaders.append(loader)
        template_source_loaders = tuple(loaders)
    for loader in template_source_loaders:
        try:
            _, display_name = loader(name)
            if display_name:
                return display_name
        except TemplateDoesNotExist:
            pass
    raise TemplateDoesNotExist(name)
742412
def on_view_not_found(
            self,
            environ: Dict[str, Any],
            start_response: Callable[[str, List[Tuple[str, str]]], None],
    ) -> Iterable[bytes]:
        
        start_response('404 Not Found', [('Content-type', 'text/plain')])
        return [b'Not found']
138645
def get_api_root_view(self, api_urls=None):
        
        api_root_dict = OrderedDict()
        list_name = self.routes[0].name
        for prefix, viewset, basename in self.registry:
            api_root_dict[prefix] = list_name.format(basename=basename)

        class APIRootView(views.APIView):
            _ignore_model_permissions = True
            exclude_from_schema = True

            def get(self, request, *args, **kwargs):
                # Return a plain {"name": "hyperlink"} response.
                ret = OrderedDict()
                namespace = request.resolver_match.namespace
                for key, url_name in sorted(api_root_dict.items(), key=itemgetter(0)):
                    if namespace:
                        url_name = namespace + ':' + url_name
                    try:
                        ret[key] = reverse(
                            url_name,
                            args=args,
                            kwargs=kwargs,
                            request=request,
                            format=kwargs.get('format', None)
                        )
                    except NoReverseMatch:
                        # Don't bail out if eg. no list routes exist, only detail routes.
                        continue

                return Response(ret)

        return APIRootView.as_view()
1253338
def get_redirect_url(self, **kwargs):
        
        if self.request.REQUEST.has_key('next'): 
            return self.request.REQUEST.get('next')
        url = RedirectView.get_redirect_url(self, **kwargs)
        if url:
            return url
        return self.request.META.get('HTTP_REFERER')
1230779
def add_view(self, path: str, handler: AbstractView,
                 **kwargs: Any) -> AbstractRoute:
        
        return self.add_route(hdrs.METH_ANY, path, handler, **kwargs)
1093526
def GetView(self, viewname):
        

        # Build Request
        soap_request = soap('GetView')
        soap_request.add_parameter('listName', self.listName)

        if viewname == None:
            views = self.GetViewCollection()
            for view in views:
                if 'DefaultView' in view:
                    if views[view]['DefaultView'] == 'TRUE':
                        viewname = view
                        break

        if self.listName not in ['UserInfo', 'User Information List']:
            soap_request.add_parameter('viewName', self.views[viewname]['Name'][1:-1])
        else:
            soap_request.add_parameter('viewName', viewname)
        self.last_request = str(soap_request)

        # Send Request
        response = self._session.post(url=self._url('Views'),
                                      headers=self._headers('GetView'),
                                      data=str(soap_request),
                                      verify=self._verify_ssl,
                                      timeout=self.timeout)

        # Parse Response
        if response.status_code == 200:
            envelope = etree.fromstring(response.text.encode('utf-8'), parser=etree.XMLParser(huge_tree=self.huge_tree))
            view = envelope[0][0][0][0]
            info = {key: value for (key, value) in view.items()}
            fields = [x.items()[0][1] for x in view[1]]
            return {'info': info, 'fields': fields}

        else:
            raise Exception("ERROR:", response.status_code, response.text)
1174403
def to_view(self, view_name):
    
    # Do the import here to avoid circular dependencies at top-level.
    from . import _view
    return _view.View(view_name, self._context).create(self._sql)
607826
def get_listing_view(self, request, queryset, opts=None):
        
        view = self.get_view(request, self.view_class, opts)
        view.queryset = queryset
        return view
793708
def get_request_from_view_args(self, view, args, kwargs):
        
        if len(args) > 1 and isinstance(args[1], sanic.request.Request):
            req = args[1]
        else:
            req = args[0]
        assert isinstance(
            req, sanic.request.Request
        ), "Request argument not found for handler"
        return req
1040174
def route(view, endpoint=None, methods=None, defaults=None, **options):
    
    if not endpoint:
        endpoint = view
    if not methods:
        methods = ['GET']
    return dict(
        view_func=LazyView(view),
        endpoint=endpoint,
        methods=methods,
        defaults=defaults,
        **options
    )
147394
def call(self, name, request=None, **params):
        
        if name not in self.resources:
            raise exceptions.HttpError(
                'Unknown method \'%s\'' % name,
                status=status.HTTP_501_NOT_IMPLEMENTED)
        request = request or HttpRequest()
        resource = self.resources[name]
        view = resource.as_view(api=self)
        return view(request, **params)
633002
function chooseViewForRoute() {
            var allParams = addExtraParamsTo(params,
                layoutDelegate,
                clientRequest,
                clientResponse
            );

            return promisify(originalHandler).apply(router, allParams)
                .then(function(view) {
                    validateView(view);

                    return {
                        view: view,
                        reason: null
                    };
                })
                .catch(function(reason) {
                    return {
                        view: null,
                        reason: reason
                    };
                });
        }
1098155
protected View getView(String viewName) {
        for (View view: solo.getCurrentViews()) {
            if (view.toString().contains(viewName)) {
                return view;
            }
        }

        return null;
    }
244043
def find_template(views, name, engine)
      yield ::File.join(views, "#{name}.#{@preferred_extension}")
      Tilt.mappings.each do |ext, engines|
        next unless ext != @preferred_extension and engines.include? engine
        yield ::File.join(views, "#{name}.#{ext}")
      end
    end