Roundup Tracker - Issues

Message7340

Author rouilj
Recipients rouilj
Date 2021-09-03.16:06:32
Message-id <1630685192.77.0.60394675748.issue2551160@roundup.psfhosted.org>
In-reply-to
Currently the actions that export CSV from an index view don't permit
transitive props.

E.G. If I had an issue view and wanted to display the email address of
the issue creator, I could access it via the tal path expression
issue/creator/address and use the @column value creator.address to key
off of in the template.

If this is passed to the CSV creator, it will complain that there is
no creator.address in issue. This is done by (added in issue 2550712):

        props = klass.getprops()
        for cname in columns:
            if cname not in props:
                # use error code 400: Bad Request. Do not use
                # error code 404: Not Found.
                self.client.response_code = 400
                raise exceptions.NotFound(
                    self._('Column "%(column)s" not found in %(class)s')
                    % {'column': html_escape(cname),
                       'class': request.classname})


right at the top of the handle method. Change this so if cname is not
in props,

   else:
     t = klass.get_transitive_prop(cname)
     if t is not None:
        props[cname] = t
     else:
       # use error code 400: Bad Request. Do not use
                # error code 404: Not Found.
                self.client.response_code = 400
                raise exceptions.NotFound(
                    self._('Column "%(column)s" not found in %(class)s')
                    % {'column': html_escape(cname),
                       'class': request.classname})

so props dict includes the transitive property as well.

Also props seems to be redefined later in the code, This is an error
we have two calls to getprops() for no reason. Remove the redefinition
keeping all validated props and transitive props for processing in the
csv emitting code.

The hasPermission call has to support transitive props or if it is a
transitive prop (i.e. column_name.index('.) doesn't raise ValueError)
check permissions transitively for each component.

Also the get() call to grab the value wil raise a KeyError on
transitvie props. Handle this by:

  * make get() handle transitive with a 'transitive' False/True flag
  * handle KeyError raised by a transitive prop call a loop/function
    to resolve transitive props to  value
  * if prop is transitive (index('.') returns number),  just loop/call
    function to get the value

Not quite clear what the best way to do this is.  I expect
non-transitive props will be majority of processing, so try to
optimize for that case.

Also add test cases for this to existing CSV tests.
History
Date User Action Args
2021-09-03 16:06:32rouiljsetrecipients: + rouilj
2021-09-03 16:06:32rouiljsetmessageid: <1630685192.77.0.60394675748.issue2551160@roundup.psfhosted.org>
2021-09-03 16:06:32rouiljlinkissue2551160 messages
2021-09-03 16:06:32rouiljcreate