Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- else:
- # If marker is not none and basestring we query it.
- # Otherwise, return all matching records
- if marker is not None:
- try:
- marker = self._find(model, context, {'id': marker},
- one=True)
- except exceptions.NotFound:
- raise exceptions.MarkerNotFound(
- 'Marker %s could not be found' % marker)
- # Malformed UUIDs return StatementError
- except sqlalchemy_exc.StatementError as value_error:
- raise exceptions.InvalidMarker(value_error.message)
- sort_key = sort_key or 'created_at'
- sort_dir = sort_dir or 'asc'
- # sort_dir is checked in paginate_query.
- # We duplicate the sort_dir check here to throw a more specific
- # exception than ValueError.
- if (sort_dir not in ['asc', 'desc']):
- raise exceptions.InvalidSortDir(_("Unknown sort direction, "
- "must be 'desc' or 'asc'"))
- try:
- query = paginate_query(
- query, model, limit,
- [sort_key, 'id', 'created_at'], marker=marker,
- sort_dir=sort_dir)
- return query.all()
- except InvalidSortKey as sort_key_error:
- raise exceptions.InvalidSortKey(sort_key_error.message)
- # Any ValueErrors are propagated back to the user as is.
- # Limits are checked at the API layer. If however central or
- # storage is called directly, invalid limits show up as
- # ValueError
- except ValueError as value_error:
- raise exceptions.ValueError(value_error.message)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement