Invoke the given :class:`.Request` instance using the associated :class:`.Dispatcher`.

        :param request: :class:`.Request` instance to invoke.
        :return: :class:`.Resource` subclass.
354569
def invoke(self, request):
        
        url = '{0}/{1}'.format(self.base_url, request.remote_path)
        r = self.httpclient.get(url, params=request.params, headers=self.get_headers())
        if 200 <= r.status_code < 300:
            return self.resource_factory.from_json(r.json())
        else:
            if r.status_code in ErrorMapping.mapping:
                raise ErrorMapping.mapping[r.status_code](r)
            else:
                raise ApiError(r)
437508
def request(self, *args, **kwargs):
        
        func = partial(super().request, *args, **kwargs)
        return self.loop.run_in_executor(self.thread_pool, func)
54124
def dispatch(self, request):
        
        login_done_url = reverse(self.adapter.provider_id + "_callback")
        client = self._get_client(request, login_done_url)
        if not client.is_valid():
            if 'denied' in request.GET:
                error = AuthError.CANCELLED
            else:
                error = AuthError.UNKNOWN
            extra_context = dict(oauth_client=client)
            return render_authentication_error(
                request,
                self.adapter.provider_id,
                error=error,
                extra_context=extra_context)
        app = self.adapter.get_provider().get_app(request)
        try:
            access_token = client.get_access_token()
            token = SocialToken(
                app=app,
                token=access_token['oauth_token'],
                # .get() -- e.g. Evernote does not feature a secret
                token_secret=access_token.get('oauth_token_secret', ''))
            login = self.adapter.complete_login(request,
                                                app,
                                                token,
                                                response=access_token)
            login.token = token
            login.state = SocialLogin.unstash_state(request)
            return complete_social_login(request, login)
        except OAuthError as e:
            return render_authentication_error(
                request,
                self.adapter.provider_id,
                exception=e)
186382
def _request(self):
        
        caller_frame = inspect.getouterframes(inspect.currentframe())[1]
        args, _, _, values = inspect.getargvalues(caller_frame[0])
        caller_name = caller_frame[3]
        kwargs = {arg: values[arg] for arg in args if arg != 'self'}
        func = reduce(
            lambda resource, name: resource.__getattr__(name),
            self.mappings[caller_name].split('.'), self)
        return func(**kwargs)
466772
def __request(self, *args, **kwargs):
        

        with self.lock:
            parent = xmlrpc.client.ServerProxy
            # pylint: disable=E1101
            return parent._ServerProxy__request(self, *args, **kwargs)
987388
def _call(self, resource_url, params=None):
        
        
        url = "%s%s" % (self._endpoint(), resource_url)
        if params:
            url += "?%s&%s" % (params, self._auth())
        else:
            url += "?%s" % self._auth()
        return requests.get(url)
391863
def command(self, resource, obj,
                operation_timeout=None, max_envelope_size=None, locale=None):
        
        if isinstance(resource, str):
            resource = ResourceLocator(resource)

        headers = self._build_headers(resource, Session.CommandAction,
                                      operation_timeout, max_envelope_size, locale)
        return self.service.invoke(headers, obj)
876745
def _call(self, method_proxy, *args):
        
        request = self._gw.addRequest(method_proxy, *args)

        if self._auto_execute:
            response = self._gw.execute_single(request)

            if response.status == remoting.STATUS_ERROR:
                if hasattr(response.body, 'raiseException'):
                    try:
                        response.body.raiseException()
                    except:
                        raise
                else:
                    raise remoting.RemotingError

            return response.body

        return request
487866
def dispatch_request(self, environ, start_response):
        """"""
        # set up all the stuff we want to have for this request.  That is
        # creating a request object, propagating the application to the
        # current context and instanciating the database session.
        self.bind_to_context()
        request = Request(environ)
        request.bind_to_context()

        # get the current action from the url and normalize the page name
        # which is just the request path
        action_name = request.args.get("action") or "show"
        page_name = u"_".join([x for x in request.path.strip("/").split() if x])

        # redirect to the Main_Page if the user requested the index
        if not page_name:
            response = redirect(href("Main_Page"))

        # check special pages
        elif page_name.startswith("Special:"):
            if page_name[8:] not in pages:
                response = page_not_found(request, page_name)
            else:
                response = pages[page_name[8:]](request)

        # get the callback function for the requested action from the
        # action module.  It's "on_" + the action name.  If it doesn't
        # exists call the missing_action method from the same module.
        else:
            action = getattr(actions, "on_" + action_name, None)
            if action is None:
                response = actions.missing_action(request, action_name)
            else:
                response = action(request, page_name)

        # make sure the session is removed properly
        return ClosingIterator(response(environ, start_response), session.remove)
191810
def invoke(self, method, relpath=None, params=None, data=None, headers=None):
    
    path = self._join_uri(relpath)
    resp = self._client.execute(method,
                                path,
                                params=params,
                                data=data,
                                headers=headers)
    try:
      body = resp.read()
    except Exception, ex:
      raise Exception("Command '%s %s' failed: %s" %
                      (method, path, ex))

    self._client.logger.debug(
        "%s Got response: %s%s" %
        (method, body[:32], len(body) > 32 and "..." or ""))

    # Is the response application/json?
    if len(body) != 0 and \
          resp.info().getmaintype() == "application" and \
          resp.info().getsubtype() == "json":
      try:
        json_dict = json.loads(body)
        return json_dict
      except Exception, ex:
        self._client.logger.exception('JSON decode error: %s' % (body,))
        raise ex
    else:
      return body
533620
def dispatch(self, *args, **kwargs):
        '''
        
        '''

        # Get if this class is working as only a base render and List funcionality shouldn't be enabled
        onlybase = getattr(self, "onlybase", False)

        # REST not available when onlybase is enabled
        if not onlybase:

            # Check if this is a REST query to pusth the answer to responde in JSON
            if bool(self.request.META.get('HTTP_X_REST', False)):
                self.json = True
                if self.request.GET.get('json', self.request.POST.get('json', None)) is None:
                    newget = {}
                    newget['json'] = "{}"
                    for key in self.request.GET:
                        newget[key] = self.request.GET[key]
                    self.request.GET = QueryDict('').copy()
                    self.request.GET.update(newget)

    #                return HttpResponseBadRequest(_("The service requires you to set a GET argument named json={} which will contains all the filters you can apply to a list"))

            # Check if this is a REST query to add an element
            if self.request.method == 'POST':
                target = get_class(resolve("{}/add".format(self.request.META.get("REQUEST_URI"))).func)
                target.json = True
                return target.as_view()(self.request)

        # Set class internal variables
        self._setup(self.request)

        # Deprecations
        deprecated = [('retrictions', '2016061000')]
        for (depre, version) in deprecated:
            if hasattr(self, depre):
                raise IOError("The attribute '{}' has been deprecated in version '{}' and it is not available anymore".format(version))

        # Build extracontext
        if not hasattr(self, 'extra_context'):
            self.extra_context = {}
        if not hasattr(self, 'client_context'):
            self.client_context = {}
        # Attach user to the extra_context
        self.extra_context['user'] = self.user

        # Attach WS entry point and STATIC entry point
        self.extra_context['ws_entry_point'] = self.BASE_URL + getattr(self, "ws_entry_point", "{0}/{1}".format(self._appname, "{0}s".format(self._modelname.lower())))

        static_partial_row_path = getattr(self, 'static_partial_row', "{0}/{1}_rows.html".format(self._appname, "{0}s".format(self._modelname.lower())))
        self.extra_context['static_partial_row'] = get_static(static_partial_row_path, self.user, self.language, self.DEFAULT_STATIC_PARTIAL_ROWS, 'html', relative=True)

        static_partial_header_path = getattr(self, 'static_partial_header', "{0}/{1}_header.html".format(self._appname, "{0}s".format(self._modelname.lower())))
        self.extra_context['static_partial_header'] = get_static(static_partial_header_path, self.user, self.language, None, 'html', relative=True)

        static_partial_summary_path = getattr(self, 'static_partial_summary', "{0}/{1}_summary.html".format(self._appname, "{0}s".format(self._modelname.lower())))
        self.extra_context['static_partial_summary'] = get_static(static_partial_summary_path, self.user, self.language, self.DEFAULT_STATIC_PARTIAL_SUMMARY, 'html', relative=True)

        static_app_row_path = getattr(self, 'static_app_row', "{0}/{1}_app.js".format(self._appname, "{0}s".format(self._modelname.lower())))
        self.extra_context['static_app_row'] = get_static(static_app_row_path, self.user, self.language, os.path.join(settings.STATIC_URL, 'codenerix/js/app.js'), 'js', relative=True)

        static_controllers_row_path = getattr(self, 'static_controllers_row', "{0}/{1}_controllers.js".format(self._appname, "{0}s".format(self._modelname.lower())))
        self.extra_context['static_controllers_row'] = get_static(static_controllers_row_path, self.user, self.language, None, 'js', relative=True)

        static_filters_row_path = getattr(self, 'static_filters_row', "{0}/{1}_filters.js".format(self._appname, "{0}s".format(self._modelname.lower())))
        self.extra_context['static_filters_row'] = get_static(static_filters_row_path, self.user, self.language, os.path.join(settings.STATIC_URL, 'codenerix/js/rows.js'), 'js', relative=True)

        self.extra_context['field_delete'] = getattr(self, 'field_delete', False)
        self.extra_context['field_check'] = getattr(self, 'field_check', None)

        # Default value for extends_base
        if hasattr(self, 'extends_base'):
            self.extra_context['extends_base'] = self.extends_base
        elif hasattr(self, 'extends_base'):
            self.extra_context['extends_base'] = self.extends_base

        # Get if this is a template only answer
        self.__authtoken = (bool(getattr(self.request, "authtoken", False)))
        self.json_worker = (hasattr(self, 'json_builder')) or self.__authtoken or (self.json is True)
        if self.json_worker:
            # Check if the request has some json query, if not, just render the template
            if self.request.GET.get('json', self.request.POST.get('json', None)) is None:
                # Calculate tabs
                if getattr(self, 'show_details', False):
                    self.extra_context['tabs_js'] = json.dumps(self.get_tabs_js())

                # Silence the normal execution from this class
                self.get_queryset = lambda: None
                self.get_context_data = lambda **kwargs: self.extra_context
                self.render_to_response = lambda context, **response_kwargs: super(GenList, self).render_to_response(context, **response_kwargs)
                # Call the base implementation and finish execution here
                return super(GenList, self).dispatch(*args, **kwargs)

        # The systems is requesting a list, we are not allowed
        if onlybase:
            json_answer = {"error": True, "errortxt": _("Not allowed, this kind of requests has been prohibited for this view!")}
            return HttpResponse(json.dumps(json_answer), content_type='application/json')

        # Initialize a default context
        self.__kwargs = kwargs
        self.__context = {}

        # Force export list
        self.export = getattr(self, 'export', self.request.GET.get('export', self.request.POST.get('export', None)))

        # Call the base implementation
        return super(GenList, self).dispatch(*args, **kwargs)
889637
def set_notify_dispatch_request(self, notify_dispatch_request, *args):
        
        self._notify_dispatch_request = notify_dispatch_request
        self._notify_args = args
327324
def dispatch(self, request, *args, **kwargs):
        
        allowed_methods = self.get_allowed_methods()
        try:
            if request.method == 'GET' and 'GET' in allowed_methods:
                if 'pk' in request.GET or self.slug_field in request.GET:
                    return self.ng_get(request, *args, **kwargs)
                return self.ng_query(request, *args, **kwargs)
            elif request.method == 'POST' and 'POST' in allowed_methods:
                return self.ng_save(request, *args, **kwargs)
            elif request.method == 'DELETE' and 'DELETE' in allowed_methods:
                return self.ng_delete(request, *args, **kwargs)
        except self.model.DoesNotExist as e:
            return self.error_json_response(e.args[0], 404)
        except NgMissingParameterError as e:
            return self.error_json_response(e.args[0])
        except JSONResponseException as e:
            return self.error_json_response(e.args[0], e.status_code)
        except ValidationError as e:
            if hasattr(e, 'error_dict'):
                return self.error_json_response('Form not valid', detail=e.message_dict)
            else:
                return self.error_json_response(e.message)

        return self.error_json_response('This view can not handle method {0}'.format(request.method), 405)
21980
def request(method, path)
        resource[path].send(method.to_sym, request_headers) { |response, request, result, &block|
          case response.code
            when 200
              response
            when 400
              if response.include? ' is required'
                raise ArgumentError.new(response)
              else
                raise BadRequestError.new(response)
              end
            else
              response.return!(request, result, &block)
          end
        }
      end
727545
def call(self, **data):
        
        uri, body, headers = self.prepare(data)
        return self.dispatch(uri, body, headers)
935455
function Dispatcher(req, res, next) {
            _classCallCheck(this, Dispatcher);

            this.req = req;
            this.res = res;
            this.next = next;
         }
442115
def _call_method(request)
      params = request.params
      resource_obj = nil
      resource_id = nil

      request.each_resource do |name, id|
        unless resource_obj
          (resource_obj = _load_resource(request.version, name)) or
            _error!(Errors::NotFoundError)
        else
          mounted_resource = resource_obj.mounts[name] or
            _error!(Errors::NotFoundError)
          resource_obj = mounted_resource.new
        end

        params.merge!(resource_obj.id_param => id) if id
        resource_id = id
      end

      resource_obj.process(request.request_method, !!resource_id, params)
    end