'Update the template context with some commonly used variables.
This injects request, session, config and g into the template
context as well as everything template context processors want
to inject.  Note that the as of Flask 0.6, the original values
in the context will not be overridden if a context processor
decides to return a value with the same key.
:param context: the context as a dictionary that is updated in place
to add extra variables.'

def update_template_context(self, context):

    funcs = self.template_context_processors[None]
    reqctx = _request_ctx_stack.top
    if (reqctx is not None):
        bp = reqctx.request.blueprint
        if ((bp is not None) and (bp in self.template_context_processors)):
            funcs = chain(funcs, self.template_context_processors[bp])
    orig_ctx = context.copy()
    for func in funcs:
        context.update(func())
    context.update(orig_ctx)
