def apply_extra_context(extra_context, context):
 for (key, value) in extra_context.iteritems():
  if callable(value):
   context[key] = value()
  else:
   context[key] = value

def apply_extra_context ( extra_context , context ) : for ( key , value ) in extra_context . iteritems ( ) : if callable ( value ) : context [ key ] = value ( ) else : context [ key ] = value
adds items from extra_context dict to context .