def query(request, slug=None, **kwargs):
    ds = get_object_or_404(DataResource, slug=slug)
    user = authorize(request, ds, view=True)

    ds.driver_instance.ready_data_resource()
    maybeint = lambda x: int(x) if x else None

    geometry_mbr = [float(kwargs[k]) for k in ['x1', 'y1', 'x2', 'y2']] if 'x1' in kwargs else None
    srid = kwargs['srid'] if 'srid' in kwargs else None
    geometry = request.REQUEST.get('g', None)
    geometry_format = request.REQUEST.get('format', 'geojson')
    geometry_operator = request.REQUEST.get('op', 'intersects')
    limit = maybeint(request.REQUEST.get('limit', None))
    start = maybeint(request.REQUEST.get('start', None))
    end = maybeint(request.REQUEST.get('end', None))
    only = request.REQUEST.get('only', None)
    if only:
        only = only.split(',')

    rest = {k: v for k, v in request.REQUEST.items() if
            k not in {'limit', 'start', 'end', 'only', 'g', 'op', 'format'}}

    rows = ds.driver_instance.query(
        query_mbr=geometry_mbr,
        query_geometry=geometry,
        geometry_format=geometry_format,
        geometry_operator=geometry_operator,
        query_geometry_srid=srid,
        limit=limit,
        start=start,
        end=end,
        only=only,
        **rest
    )

    dispatch.api_accessed.send(sender=DataResource, instance=ds, user=user)
    dispatch.features_retrieved.send(sender=DataResource, instance=ds, user=user, count=len(rows))
    return json_or_jsonp(request, rows)
dataset/ETHPy150Open hydroshare/hydroshare2/ga_resources/views/rest_data.py/query/original