'Parse a limit query param into something usable.'

def _get_limit(self, req):

    try:
        limit = int(req.params.get('limit', CONF.limit_param_default))
    except ValueError:
        raise exc.HTTPBadRequest(_('limit    param    must    be    an    integer'))
    if (limit < 0):
        raise exc.HTTPBadRequest(_('limit    param    must    be    positive'))
    return min(CONF.api_limit_max, limit)
