Beispiel #1
0
    def generator(self, req, generator, count=0, args=None):
        """Response generator.

        It also determines pagination and ordering.

        Todo:
            (mort) remove req and replace it by args.

        Args:
            req (Request): Falcon request object.
            generator (Callable): callable function/method to get data.
            count (int): number of items which should be get.
            args (Dict): query parameters.

        Returns:
            Tuple: generated response.
        """
        if not args:
            args = _parse_qs(req)
        top = int(args['$top'][0]) if '$top' in args else DEFAULT_TOP
        skip = int(args['$skip'][0]) if '$skip' in args else 0
        order = args['$orderby'][0].split(',') if '$orderby' in args else None
        if order:
            order = tuple(('-' if len(o.split()) > 1 and o.split()[1] == 'desc' else '')+o.split()[0] for o in order)

        return generator(page_start=skip, page_limit=top, order=order), top, skip, count
Beispiel #2
0
 def generator(self, req, generator, count=0):
     # determine pagination and ordering
     args = _parse_qs(req)
     top = int(args['$top'][0]) if '$top' in args else DEFAULT_TOP
     skip = int(args['$skip'][0]) if '$skip' in args else 0
     order = args['$orderby'][0].split(',') if '$orderby' in args else None
     if order:
         order = tuple(('-' if len(o.split()) > 1 and o.split()[1] == 'desc' else '')+o.split()[0] for o in order)
     return (generator(page_start=skip, page_limit=top, order=order), top, skip, count)
Beispiel #3
0
    def _gen_restriction(req, store):
        """Generate a restriction for folders based on request params.

        Args:
            req (Request): Falcon request object.
            store (Store): user's store object.

        Returns:
            Restriction: generated restriction object.
            None: when the request has no '$search' param.
        """
        args = _parse_qs(req)
        query = args["$search"] if '$search' in args else None
        if not query:
            return None

        return _query_to_restriction(query[0], "folder", store)
Beispiel #4
0
def _start_end(req):
    args = _parse_qs(req)
    return _parse_date(args, 'startDateTime'), _parse_date(args, 'endDateTime')