def list_by_context(request, model_cls, context):
    """List records by a given context

    """
    model = model_cls(request.model_factory)
    offset = int(request.params.get('offset', 0))
    limit = int(request.params.get('limit', 20))
    kwargs = {}
    if 'external_id' in request.params:
        kwargs['external_id'] = request.params['external_id']
    if 'processor_uri' in request.params:
        kwargs['processor_uri'] = request.params['processor_uri']
    items = model.list_by_context(
        context=context,
        offset=offset,
        limit=limit,
        **kwargs
    )
    result = dict(
        items=list(items),
        offset=offset,
        limit=limit,
    )
    return result