Modify

Opened 4 years ago

Last modified 16 months ago

#7185 new enhancement

[PATCH] Improve "id" field handling in reports

Reported by: matthijs Owned by: rjollos
Priority: normal Component: BlackMagicTicketTweaksPlugin
Severity: normal Keywords: patch
Cc: ivanelson Trac Release: 0.11

Description

The plugin incorrectly assumes that there will be a field "id" in each row of the report view. Also, it assumes that the "id" field references a ticket, while it may reference other things (like reports. commits, wikipages) through the setting of the "realm" field. Finally, there is the "ticket" field, which can also contain the ticket id. See http://trac.edgewall.org/wiki/TracReports#Automaticallyformattedcolumns for details.

The attached patch fixes all three of these issues. Note that it resorts to not applying access control when no id field is present or it does not reference a ticket, since then it cannot know which ticket is being displayed.

Attachments (1)

optional-id.patch (4.2 KB) - added by matthijs 4 years ago.
Patch against 0.11 version, r8017

Download all attachments as: .zip

Change History (9)

Changed 4 years ago by matthijs

Patch against 0.11 version, r8017

comment:1 Changed 4 years ago by matthijs

Note that the patch looks big, but everything after if id: is only indented one level, no other changes.

comment:2 Changed 16 months ago by rjollos

  • Cc ivanelson added
  • Owner changed from obs to rjollos
  • Status changed from new to assigned

#11140 closed as a duplicate.

comment:3 Changed 16 months ago by rjollos

In 13282:

Refs #7185: Added additional checks for existence of variables since some parameters may not exist for all reports.

comment:4 follow-up: Changed 16 months ago by rjollos

ivanelson: I wasn't able to add your report from comment:2:ticket:11140 without seeing errors. Which database are you using? I expect more changes may be needed after [13282], but please do some testing and report back.

Last edited 16 months ago by rjollos (previous) (diff)

comment:5 in reply to: ↑ 4 ; follow-up: Changed 16 months ago by ivanelson

Replying to rjollos:

ivanelson: I wasn't able to add your report from comment:2:ticket:11140 without seeing errors. Which database are you using? I expect more changes may be needed after [13282], but please do some testing and report back.

I am using Postgres. The error has changed:

2013-06-11 23:53:30,100 Trac[main] ERROR: Internal Server Error: 
Traceback (most recent call last):
  File "/usr/local/lib/python2.7/dist-packages/Trac-1.0-py2.7.egg/trac/web/main.py", line 497, in _dispatch_request
    dispatcher.dispatch(req)
  File "/usr/local/lib/python2.7/dist-packages/Trac-1.0-py2.7.egg/trac/web/main.py", line 233, in dispatch
    content_type)
  File "/usr/local/lib/python2.7/dist-packages/Trac-1.0-py2.7.egg/trac/web/chrome.py", line 1000, in render_template
    encoding='utf-8')
  File "/usr/lib/python2.7/dist-packages/genshi/core.py", line 183, in render
    return encode(generator, method=method, encoding=encoding, out=out)
  File "/usr/lib/python2.7/dist-packages/genshi/output.py", line 58, in encode
    for chunk in iterator:
  File "/usr/lib/python2.7/dist-packages/genshi/output.py", line 339, in __call__
    for kind, data, pos in stream:
  File "/usr/lib/python2.7/dist-packages/genshi/output.py", line 826, in __call__
    for kind, data, pos in stream:
  File "/usr/lib/python2.7/dist-packages/genshi/output.py", line 670, in __call__
    for kind, data, pos in stream:
  File "/usr/lib/python2.7/dist-packages/genshi/output.py", line 771, in __call__
    for kind, data, pos in chain(stream, [(None, None, None)]):
  File "/usr/lib/python2.7/dist-packages/genshi/output.py", line 586, in __call__
    for ev in stream:
  File "/usr/lib/python2.7/dist-packages/genshi/core.py", line 288, in _ensure
    for event in stream:
  File "/usr/lib/python2.7/dist-packages/genshi/core.py", line 288, in _ensure
    for event in stream:
  File "/usr/local/lib/python2.7/dist-packages/Trac-1.0-py2.7.egg/trac/web/chrome.py", line 1137, in _strip_accesskeys
    for kind, data, pos in stream:
  File "/usr/lib/python2.7/dist-packages/genshi/core.py", line 288, in _ensure
    for event in stream:
  File "/usr/local/lib/python2.7/dist-packages/Trac-1.0-py2.7.egg/trac/web/chrome.py", line 1126, in _generate
    for kind, data, pos in stream:
  File "/usr/lib/python2.7/dist-packages/genshi/core.py", line 288, in _ensure
    for event in stream:
  File "/usr/lib/python2.7/dist-packages/genshi/core.py", line 288, in _ensure
    for event in stream:
  File "/usr/lib/python2.7/dist-packages/genshi/filters/transform.py", line 686, in _unmark
    for mark, event in stream:
  File "/usr/lib/python2.7/dist-packages/genshi/filters/transform.py", line 906, in __call__
    for mark, event in stream:
  File "/usr/lib/python2.7/dist-packages/genshi/filters/transform.py", line 714, in __call__
    for mark, event in stream:
  File "/usr/lib/python2.7/dist-packages/genshi/filters/transform.py", line 682, in _mark
    for event in stream:
  File "/usr/lib/python2.7/dist-packages/genshi/template/base.py", line 605, in _include
    for event in stream:
  File "/usr/lib/python2.7/dist-packages/genshi/template/markup.py", line 378, in _match
    ctxt, start=idx + 1, **vars):
  File "/usr/lib/python2.7/dist-packages/genshi/template/markup.py", line 378, in _match
    ctxt, start=idx + 1, **vars):
  File "/usr/lib/python2.7/dist-packages/genshi/template/markup.py", line 362, in _match
    content = list(content)
  File "/usr/lib/python2.7/dist-packages/genshi/template/base.py", line 605, in _include
    for event in stream:
  File "/usr/lib/python2.7/dist-packages/genshi/template/markup.py", line 327, in _match
    for event in stream:
  File "/usr/lib/python2.7/dist-packages/genshi/template/markup.py", line 316, in _strip
    event = next()
  File "/usr/lib/python2.7/dist-packages/genshi/template/base.py", line 545, in _flatten
    for kind, data, pos in stream:
  File "/usr/lib/python2.7/dist-packages/genshi/core.py", line 288, in _ensure
    for event in stream:
  File "/usr/lib/python2.7/dist-packages/genshi/path.py", line 588, in _generate
    subevent = next()
  File "/usr/lib/python2.7/dist-packages/genshi/template/base.py", line 605, in _include
    for event in stream:
  File "/usr/lib/python2.7/dist-packages/genshi/template/markup.py", line 316, in _strip
    event = next()
  File "/usr/lib/python2.7/dist-packages/genshi/template/base.py", line 545, in _flatten
    for kind, data, pos in stream:
  File "/usr/lib/python2.7/dist-packages/genshi/core.py", line 288, in _ensure
    for event in stream:
  File "/usr/lib/python2.7/dist-packages/genshi/path.py", line 588, in _generate
    subevent = next()
  File "/usr/lib/python2.7/dist-packages/genshi/template/base.py", line 605, in _include
    for event in stream:
  File "/usr/lib/python2.7/dist-packages/genshi/template/markup.py", line 316, in _strip
    event = next()
  File "/usr/lib/python2.7/dist-packages/genshi/template/base.py", line 565, in _flatten
    result = _eval_expr(data, ctxt, vars)
  File "/usr/lib/python2.7/dist-packages/genshi/template/base.py", line 277, in _eval_expr
    retval = expr.evaluate(ctxt)
  File "/usr/lib/python2.7/dist-packages/genshi/template/eval.py", line 178, in evaluate
    return eval(self.code, _globals, {'__data__': data})
  File "/usr/local/lib/python2.7/dist-packages/Trac-1.0-py2.7.egg/trac/ticket/templates/report_view.html", line 165, in <Expression u"format_date(from_utimestamp(long(cell.value))) if cell.value != '' else '--'">
    <td class="date" py:attrs="td_attrs">${format_date(from_utimestamp(long(cell.value))) if cell.value != '' else '--'}
ValueError: invalid literal for long() with base 10: '24/08/2012'

comment:6 in reply to: ↑ 5 ; follow-up: Changed 16 months ago by jun66j5

Replying to ivanelson:

I am using Postgres. The error has changed:

  File "/usr/local/lib/python2.7/dist-packages/Trac-1.0-py2.7.egg/trac/ticket/templates/report_view.html", line 165, in <Expression u"format_date(from_utimestamp(long(cell.value))) if cell.value != '' else '--'">
    <td class="date" py:attrs="td_attrs">${format_date(from_utimestamp(long(cell.value))) if cell.value != '' else '--'}
ValueError: invalid literal for long() with base 10: '24/08/2012'

That is your SQL has the issue in TracReports, not the plugin.

Also, the following in your SQL

       to_char(to_timestamp(t.time/1000000),'DD/MM/YYYY') AS Created,

should be

       t.time AS Created,

See TracReports#Automaticallyformattedcolumns.

comment:7 in reply to: ↑ 6 Changed 16 months ago by ivanelson

Replying to jun66j5:

Replying to ivanelson:

I am using Postgres. The error has changed:

  File "/usr/local/lib/python2.7/dist-packages/Trac-1.0-py2.7.egg/trac/ticket/templates/report_view.html", line 165, in <Expression u"format_date(from_utimestamp(long(cell.value))) if cell.value != '' else '--'">
    <td class="date" py:attrs="td_attrs">${format_date(from_utimestamp(long(cell.value))) if cell.value != '' else '--'}
ValueError: invalid literal for long() with base 10: '24/08/2012'

That is your SQL has the issue in TracReports, not the plugin.

Also, the following in your SQL

       to_char(to_timestamp(t.time/1000000),'DD/MM/YYYY') AS Created,

should be

       t.time AS Created,

See TracReports#Automaticallyformattedcolumns.

Solved! Thank you.

comment:8 Changed 16 months ago by rjollos

  • Status changed from assigned to new

Add Comment

Modify Ticket

Action
as new .
Author


E-mail address and user name can be saved in the Preferences.

 
Note: See TracTickets for help on using tickets.