def get_context(request, model=None):
<EOL>param_values = get_param_values(request, model=model)<EOL>context = param_values.pop('<STR_LIT>', {})<EOL>if isinstance(context, (unicode, str)):<EOL><INDENT>context = projex.rest.unjsonify(context)<EOL><DEDENT>has_limit = '<STR_LIT>' in context or '<STR_LIT>' in param_values<EOL>orb_context = orb.Context(**context)<EOL>used = set()<EOL>query_context = {}<EOL>for key in orb.Context.Defaults:<EOL><INDENT>if key in param_values:<EOL><INDENT>used.add(key)<EOL>query_context[key] = param_values.get(key)<EOL><DEDENT><DEDENT>schema_values = {}<EOL>if model:<EOL><INDENT>for key, value in request.matchdict.items():<EOL><INDENT>if model.schema().column(key, raise_=False):<EOL><INDENT>schema_values[key] = value<EOL><DEDENT><DEDENT>for key, value in param_values.items():<EOL><INDENT>root_key = key.split('<STR_LIT:.>')[<NUM_LIT:0>]<EOL>schema_object = model.schema().column(root_key, raise_=False) or model.schema().collector(root_key)<EOL>if schema_object:<EOL><INDENT>value = param_values.pop(key)<EOL>if isinstance(schema_object, orb.Collector) and type(value) not in (tuple, list):<EOL><INDENT>value = [value]<EOL><DEDENT>schema_values[key] = value<EOL><DEDENT><DEDENT><DEDENT>query_context['<STR_LIT>'] = {<EOL>'<STR_LIT>': request<EOL>}<EOL>try:<EOL><INDENT>default_context = request.orb_default_context<EOL><DEDENT>except AttributeError:<EOL><INDENT>try:<EOL><INDENT>query_context['<STR_LIT>'].update(request.orb_scope)<EOL><DEDENT>except AttributeError:<EOL><INDENT>pass<EOL><DEDENT><DEDENT>else:<EOL><INDENT>if '<STR_LIT>' in default_context:<EOL><INDENT>query_context['<STR_LIT>'].update(default_context.pop('<STR_LIT>'))<EOL><DEDENT>for k, v in default_context.items():<EOL><INDENT>query_context.setdefault(k, v)<EOL><DEDENT><DEDENT>orb_context.update(query_context)<EOL>return schema_values, orb_context<EOL>
Extracts ORB context information from the request.

:param request: <pyramid.request.Request>
:param model: <orb.Model> || None

:return: {<str> key: <variant> value} values, <orb.Context>