Preprocess the request i.e. call before_request functions.

        Arguments:
            request_context: The request context, optional as Flask
                omits this argument.
183642
async def preprocess_request(
        self, request_context: Optional[RequestContext]=None,
    ) -> Optional[ResponseReturnValue]:
        
        request_ = (request_context or _request_ctx_stack.top).request
        blueprint = request_.blueprint
        processors = self.url_value_preprocessors[None]
        if blueprint is not None:
            processors = chain(processors, self.url_value_preprocessors[blueprint])  # type: ignore
        for processor in processors:
            processor(request.endpoint, request.view_args)

        functions = self.before_request_funcs[None]
        if blueprint is not None:
            functions = chain(functions, self.before_request_funcs[blueprint])  # type: ignore
        for function in functions:
            result = await function()
            if result is not None:
                return result
        return None
403015
def when_i_send_the_request(context, method):
    
    data = context.apiRequestData
    context.apiRequest = context.apiClient.generic(
        method,
        data['url'],
        data=json.dumps(data['params']),
        content_type=data['content-type'],
        format=data['format'],
    )
204048
def set_meta(request):
    
    context_extras = {}
    if not request.is_ajax() and hasattr(request, 'upy_context') and request.upy_context['PAGE']:
        context_extras['PAGE'] = request.upy_context['PAGE']
        context_extras['NODE'] = request.upy_context['NODE']
    return context_extras
91573
def request_context(app, request):
    
    vars = {}
    if request.view_args is not None:
        vars.update(request.view_args)
    vars.update({
        "request": request,
        "GET": AttrDict(request.args.to_dict()),
        "POST" : AttrDict(request.form.to_dict()),
        "app": app,
        "config": app.config,
        "session": session,
        "g": g,
        "now": datetime.datetime.now,
        "utcnow": datetime.datetime.utcnow,
        "today": datetime.date.today})
    context = Context(vars)
    context.vars["current_context"] = context
    return context
1187162
protected function before(Context $context)
    {
        // kernel before handler
        $context = parent::before($context);

        // add templater to context
        $context->templater = $this->templater;

        // prepare templater helpers and globals vars
        $this->templater->vars['ctx'] = $context;
        $this->templater->helpers['url'] = [$context, 'url'];
        $this->templater->helpers['call'] = [$context, 'forward'];

        return $context;
    }
698754
def prepare_request(self, request):
        """"""
        try:
            request_id = local.request_id
        except AttributeError:
            request_id = NO_REQUEST_ID

        if self.request_id_header and request_id != NO_REQUEST_ID:
            request.headers[self.request_id_header] = request_id

        return super(Session, self).prepare_request(request)
13433
def initialize_context(self, request: HttpRequest, *args, **kwargs) -> None:
        
        for key in self.CONTEXT_KEYS:
            setattr(self, key, kwargs.get(key))
        for key in self.QUERY_CONTEXT_KEYS:
            setattr(self, key, request.query_params.get(key))
        self._initialize_context()
        self.validate_context()
1103589
def exec_before_request_actions(actions, **kwargs):
    
    groups = ("before", "before_" + flask.request.method.lower())
    return execute_actions(actions, limit_groups=groups, **kwargs)
267086
protected void beforeSend(RpcInternalContext context, SofaRequest request) {
        currentRequests.incrementAndGet();
        context.setLocalAddress(localAddress());
    }
706576
def _init_request_hooks(self):
        
        for method_type in ('pre', 'post'):
            for method in _METHODS:
                event = getattr(self.app, 'on_' + method_type + '_' + method)
                event_hook = getattr(hooks, method_type + '_' + method)
                event += event_hook
111778
protected void preOperation(AipRequest request) {
        if (needAuth()) {
            getAccessToken(config);
        }

        request.setHttpMethod(HttpMethodName.POST);
        request.addHeader(Headers.CONTENT_TYPE, HttpContentType.FORM_URLENCODE_DATA);
        request.addHeader("accept", "*/*");
        request.setConfig(config);
    }
467827
public function beforeRequest()
    {
        $this->_ajax = array();

        if (count($this->beforeRequestEvents) > 0) {
            foreach ($this->beforeRequestEvents as $event) {
                $event->onEvent($this);
            }
        }
    }
1315290
def process_request(self, request, response):
        
        sid = request.cookies.get(self.cookie_name, None)
        data = {}
        if sid is not None:
            if self.store.exists(sid):
                data = self.store.get(sid)
        request.context.update({self.context_name: data})
117287
def pluginkit_beforerequest():
    """"""
    authMethod = current_app.config.get("PLUGINKIT_AUTHMETHOD")
    authResult = dict(msg=None, code=1, method=authMethod)

    def authTipmsg(authResult, code=403):
        """make response message"""
        return "%s Authentication failed [%s]: %s [%s]" % (code, authResult["method"], authResult["msg"], authResult["code"])

    if authMethod == "BOOL":
        """Boolean Auth"""
        PLUGINKIT_AUTHFIELD = current_app.config.get("PLUGINKIT_AUTHFIELD")
        if PLUGINKIT_AUTHFIELD:
            if PLUGINKIT_AUTHFIELD is True:
                authResult.update(code=0)
        else:
            if hasattr(g, "signin") and g.signin is True:
                authResult.update(code=0)
        authResult.update(code=10000, msg="Invalid authentication field")

    elif authMethod == "BASIC":
        """HTTP Basic Auth"""

        #: the realm parameter is reserved for defining protection spaces and
        #: it's used by the authentication schemes to indicate a scope of protection.
        #:
        #: .. versionadded:: 1.2.0
        authRealm = current_app.config.get("PLUGINKIT_AUTHREALM") or "Flask-PluginKit Login Required"

        #: User and password configuration, format {user:pass, user:pass},
        #: if format error, all authentication failure by default.
        #:
        #: .. versionadded:: 1.2.0
        authUsers = current_app.config.get("PLUGINKIT_AUTHUSERS")

        def verify_auth(username, password):
            """Check the user and password"""
            if isinstance(authUsers, dict) and username in authUsers:
                return password == authUsers[username]
            return False

        def not_authenticated():
            """Sends a 401 response that enables basic auth"""
            return Response(authTipmsg(authResult, 401), 401,
                            {'WWW-Authenticate': 'Basic realm="%s"' % authRealm})

        #: Intercepts authentication and denies access if it fails
        auth = request.authorization
        if not auth or not verify_auth(auth.username, auth.password):
            authResult.update(code=10001, msg="Invalid username or password")
            return not_authenticated()
        else:
            authResult.update(code=0)

    else:
        authResult.update(code=0, msg="No authentication required", method=None)

    #: return response if code != 0
    if authResult["code"] != 0:
        return make_response(authTipmsg(authResult)), 403

    #: get all plugins based flask-pluginkit
    if hasattr(current_app, "extensions") and "pluginkit" in current_app.extensions:
        g.plugin_manager = current_app.extensions["pluginkit"]
        g.plugins = g.plugin_manager.get_all_plugins
849041
def process_request(self, request):
        
        site = request.site
        cache_key = '{prefix}-{site}'.format(prefix=settings.REDIRECT_CACHE_KEY_PREFIX, site=site.domain)
        redirects = cache.get(cache_key)
        if redirects is None:
            redirects = {redirect.old_path: redirect.new_path for redirect in Redirect.objects.filter(site=site)}
            cache.set(cache_key, redirects, settings.REDIRECT_CACHE_TIMEOUT)
        redirect_to = redirects.get(request.path)
        if redirect_to:
            return redirect(redirect_to, permanent=True)
1201133
def before_render(self):
        
        # Render the Add button if the user has the AddClient permission
        if check_permission(AddMethod, self.context):
            self.context_actions[_("Add")] = {
                "url": "createObject?type_name=Method",
                "icon": "++resource++bika.lims.images/add.png"
            }
        # Don't allow any context actions on the Methods folder
        self.request.set("disable_border", 1)
552675
def request(self,
                method: str,
                url: StrOrURL,
                **kwargs: Any) -> '_RequestContextManager':
        """"""
        return _RequestContextManager(self._request(method, url, **kwargs))