def parse_req(self, request, rqdata, **kw):
        """Parse the incoming HttpRequest and translate it into keyword
        arguments to be used by :meth:`setup`.

        The `mt` url param is parsed only when needed. Usually it is
        not needed because the `master_class` is constant and known
        per actor. But there are exceptions:

        - `master` is `ContentType`

        - `master` is some abstract model

        - `master` is not a subclass of Model, e.g.
          :class:`lino.modlib.polls.models.AnswersByResponse`, a
          virtual table which defines :meth:`get_row_by_pk
          <lino.core.actors.Actor.get_row_by_pk>`.

        """
        # logger.info("20120723 %s.parse_req() %s", self.actor, rqdata)
        #~ rh = self.ah
        master = kw.get('master', self.actor.master)
        if master is not None:

            if not isinstance(master, type):
                raise Exception("20150216 not a type: %r" % master)
            if settings.SITE.is_installed('contenttypes'):
                from django.contrib.contenttypes.models import ContentType
                if issubclass(master, models.Model) and (
                        master is ContentType or master._meta.abstract):
                    mt = rqdata.get(constants.URL_PARAM_MASTER_TYPE)
                    try:
                        master = kw['master'] = ContentType.objects.get(
                            pk=mt).model_class()
                    except ContentType.DoesNotExist:
                        pass
                        # master is None

            if 'master_instance' not in kw:
                pk = rqdata.get(constants.URL_PARAM_MASTER_PK, None)
                #~ print '20100406a', self.actor,URL_PARAM_MASTER_PK,"=",pk
                #~ if pk in ('', '-99999'):
                if pk == '':
                    pk = None
                if pk is None:
                    kw['master_instance'] = None
                else:
                    mi = self.actor.get_master_instance(self, master, pk)
                    if mi is None:
                        raise ObjectDoesNotExist(
                            "Invalid master key {0} for {1}".format(
                                pk, self.actor))
                    kw['master_instance'] = mi

                # ~ print '20100212', self #, kw['master_instance']
        #~ print '20100406b', self.actor,kw

        if settings.SITE.use_filterRow:
            exclude = dict()
            for f in self.ah.store.fields:
                if f.field:
                    filterOption = rqdata.get(
                        'filter[%s_filterOption]' % f.field.name)
                    if filterOption == 'empty':
                        kw[f.field.name + "__isnull"] = True
                    elif filterOption == 'notempty':
                        kw[f.field.name + "__isnull"] = False
                    else:
                        filterValue = rqdata.get('filter[%s]' % f.field.name)
                        if filterValue:
                            if not filterOption:
                                filterOption = 'contains'
                            if filterOption == 'contains':
                                kw[f.field.name + "__icontains"] = filterValue
                            elif filterOption == 'doesnotcontain':
                                exclude[f.field.name +
                                        "__icontains"] = filterValue
                            else:
                                print("unknown filterOption %r" % filterOption)
            if len(exclude):
                kw.update(exclude=exclude)

        if settings.SITE.use_gridfilters:
            filter = rqdata.get(constants.URL_PARAM_GRIDFILTER, None)
            if filter is not None:
                filter = json.loads(filter)
                kw['gridfilters'] = [constants.dict2kw(flt) for flt in filter]

        kw = ActionRequest.parse_req(self, request, rqdata, **kw)
        #~ raise Exception("20120121 %s.parse_req(%s)" % (self,kw))

        #~ kw.update(self.report.known_values)
        #~ for fieldname, default in self.report.known_values.items():
            #~ v = request.REQUEST.get(fieldname,None)
            #~ if v is not None:
                #~ kw[fieldname] = v

        quick_search = rqdata.get(constants.URL_PARAM_FILTER, None)
        if quick_search:
            kw.update(quick_search=quick_search)

        sort = rqdata.get(constants.URL_PARAM_SORT, None)
        if sort:
            sort_dir = rqdata.get(constants.URL_PARAM_SORTDIR, 'ASC')
            if sort_dir == 'DESC':
                sort = '-' + sort
            kw.update(order_by=[sort])

        try:
            offset = rqdata.get(constants.URL_PARAM_START, None)
            if offset:
                kw.update(offset=int(offset))
            limit = rqdata.get(
                constants.URL_PARAM_LIMIT, self.actor.preview_limit)
            if limit:
                kw.update(limit=int(limit))
        except __HOLE__:
            # Example: invalid literal for int() with base 10:
            # 'fdpkvcnrfdybhur'
            raise SuspiciousOperation("Invalid value for limit or offset")

        return self.actor.parse_req(request, rqdata, **kw)
dataset/ETHPy150Open lsaffre/lino/lino/core/tablerequest.py/TableRequest.parse_req