Update context with context_processors from settings
    Usage:
        from codenerix.helpers import context_processors_update
        context_processors_update(context, self.request)
512284
def context_processors_update(context, request):
    '''
    
    '''
    for template in settings.TEMPLATES:
        for context_processor in template['OPTIONS']['context_processors']:
            path = context_processor.split('.')
            name = path.pop(-1)
            processor = getattr(importlib.import_module('.'.join(path)), name, None)
            if processor:
                context.update(processor(request))
    return context
86838
def refresh_context(self):
        
        User = self.model('res.user')

        self.context = User.get_preferences(True)
        return self.context
1056626
def update_request(self, request: HttpRequest):
        

        request.axes_attempt_time = now()
        request.axes_ip_address = get_client_ip_address(request)
        request.axes_user_agent = get_client_user_agent(request)
        request.axes_path_info = get_client_path_info(request)
        request.axes_http_accept = get_client_http_accept(request)
522228
def _update_request_context_with_user(self, user=None):
        ''''''

        ctx = _request_ctx_stack.top
        ctx.user = self.anonymous_user() if user is None else user
1008792
def apply_to_request(context, rack_env:, for_type:)
      req = rails_req?(rack_env) ? rack_env : Rack::Request.new(rack_env)

      context.request = Context::Request.new unless context.request
      request = context.request

      request.socket = Context::Request::Socket.new(req)
      request.http_version = build_http_version rack_env
      request.method = req.request_method
      request.url = Context::Request::Url.new(req)

      request.body = should_capture_body?(for_type) ? get_body(req) : SKIPPED

      headers, env = get_headers_and_env(rack_env)
      request.headers = headers if config.capture_headers?
      request.env = env if config.capture_env?

      context
    end
680878
private void initRequestFromRpcContext(CmsContainerPageRpcContext context) {

        if (context.getTemplateContext() != null) {
            getRequest().setAttribute(
                CmsTemplateContextManager.ATTR_RPC_CONTEXT_OVERRIDE,
                context.getTemplateContext());
        }
    }
827650
def inject_context(self, __context_dict__=None, **context):
        
        context = context or __context_dict__
        self.context_keys |= set(context.keys())
        for key, value in context.items():
            setattr(self, key, value)
        for command in self.subcommands.values():
            command.inject_context(context)
1139402
def get_context_data(self, parent_context, *tag_args, **tag_kwargs):
        
        target_object = tag_args[0]  # moved one spot due to .pop(0)
        new_context = {
            'STATIC_URL': parent_context.get('STATIC_URL', None),
            'USE_THREADEDCOMMENTS': appsettings.USE_THREADEDCOMMENTS,
            'target_object': target_object,
        }

        # Be configuration independent:
        if new_context['STATIC_URL'] is None:
            try:
                request = parent_context['request']
            except KeyError:
                new_context.update({'STATIC_URL': settings.STATIC_URL})
            else:
                new_context.update(context_processors.static(request))

        return new_context
1343840
def context_processor(self, fn):
        
        self._defer(lambda bp: bp.context_processor(fn))
        return fn
1060024
def context_loader(self, callback):
        
        if not callback or not callable(callback):
            raise Exception("Please pass in a callable that loads your context.")
        self.context_loader_callback = callback
        return callback
450967
def _update(self, **kwargs):
        
        for key, value in _iteritems(kwargs):
            if key == 'settings':
                if isinstance(value, dict):
                    if self.settings is None:
                        self.settings = Settings(**value)
                    else:
                        self.settings._update(**value)
                else:
                    self.settings = copy.deepcopy(value)
            else:
                setattr(self, key, value)
283684
def context_processor(request):
    
    from .models import Application
    ctx = {}

    if request.user.is_authenticated:
        person = request.user
        my_applications = Application.objects.get_for_applicant(person)
        requires_attention = Application.objects.requires_attention(request)

        ctx['pending_applications'] = (
            my_applications.count() + requires_attention.count()
        )

    return ctx
520204
def inject_context(context):
    
    context_path = tasks.get_context_path()
    try:
        new_context = json.loads(context)
    except ValueError:
        print('Couldn\'t load context parameter')
        return
    with open(context_path) as jsonfile:
        try:
            jsondata = json.loads(jsonfile.read())
            jsondata.update(new_context)
        except ValueError:
            print('Couldn\'t read context.json')
            return
    with open(context_path, 'w') as jsoncontent:
        json.dump(jsondata, jsoncontent, indent=4)
118724
private void adjustRequestProcessorsPool()
    {
        assertLocked();

        AttrRequests attrRequests = cmParams.getRequests();

        int requests
            = attrRequests != null
                ? attrRequests.intValue() : 2;

        // NOTE In polling mode with default WAIT=60 connection
        //      will be unresponsive
        if (requests <= 1 && "1".equals(String.valueOf(cmParams.getHold()))) {
            LOG.warning(
                "CM supports only 1 requests at a time and there is"
                    + " a risk of connection being stuck up to "
                    + cmParams.getWait() + "seconds");
        }

        // Expand request processors pool
        if (requests > procThreads.length) {

            RequestProcessor[] oldProcessors = procThreads;
            procThreads = new RequestProcessor[requests];

            System.arraycopy(
                oldProcessors, 0, procThreads, 0, oldProcessors.length);

            for (int i = oldProcessors.length; i < requests; i++) {
                procThreads[i] = new RequestProcessor(i);
                procThreads[i].start();
            }
        }
    }
1368636
def do_api_calls_update_cache(self):
        '''  '''
        zones = self.parse_env_zones()
        data = self.group_instances(zones)
        self.cache.write_to_cache(data)
        self.inventory = data
439749
def _get_operations(self, context):
        """"""
        #Most of the time, the real-time update is going to fire with
        #incomplete statements that don't result in any changes being made
        #to the module instances. The SequenceMatches caches hashes for the
        #second argument. Logically, we want to turn the cached version into
        #the buffer version; however, the buffer is the string that keeps 
        #changing.

        #in order to optimize the real-time update, we *switch* the two strings
        #when we set the sequence and then fix the references on the operations
        #after the fact.
        if context.module.changed or self.unset:
            self.matcher.set_seq2(context.cachedstr)
            self.unset = False
            #Set the changed flag back to false now that the sequencer has
            #reloaded it.
            context.module.changed = False
        self.matcher.set_seq1(context.bufferstr)

        opcodes = self.matcher.get_opcodes()
        result = []

        #Index i keeps track of how many operations were actually added because
        #they constituted a change we need to take care of.
        i = 0
        for code in opcodes:
            if code[0] != "equal":
                #Replacements don't have a mode change. All of the operations
                #switch the order of the line indices for the two strings.
                if code[0] == "insert":
                    newcode = ("delete", code[3], code[4], code[1], code[2])
                elif code[0] == "delete":
                    newcode = ("insert", code[3], code[4], code[1], code[2])
                else:
                    newcode = ("replace", code[3], code[4], code[1], code[2])

                op = Operation(context, self.parser, newcode, i)
                result.append(op)
                i += 1

        return result
620643
public void processRequest(RequestContext context) throws Exception {
        if (processorIterator.hasNext()){
            RequestSecurityProcessor processor = processorIterator.next();

            logger.debug("Executing processor {}", processor);

            processor.processRequest(context, this);
        }
    }