Modify

Opened 15 years ago

Closed 5 years ago

#7185 closed enhancement (wontfix)

[PATCH] Improve "id" field handling in reports

Reported by: Matthijs Kooijman Owned by: Ryan J Ollos
Priority: normal Component: BlackMagicTicketTweaksPlugin
Severity: normal Keywords: patch
Cc: Ivanelson Nunes 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 Kooijman 15 years ago.
Patch against 0.11 version, r8017

Download all attachments as: .zip

Change History (10)

Changed 15 years ago by Matthijs Kooijman

Attachment: optional-id.patch added

Patch against 0.11 version, r8017

comment:1 Changed 15 years ago by Matthijs Kooijman

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

comment:2 Changed 12 years ago by Ryan J Ollos

Cc: Ivanelson Nunes added; anonymous removed
Owner: changed from obs to Ryan J Ollos
Status: newassigned

#11140 closed as a duplicate.

comment:3 Changed 12 years ago by Ryan J Ollos

In 13282:

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

comment:4 Changed 12 years ago by Ryan J Ollos

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 12 years ago by Ryan J Ollos (previous) (diff)

comment:5 in reply to:  4 ; Changed 12 years ago by Ivanelson Nunes

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 ; Changed 12 years ago by Jun Omae

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 12 years ago by Ivanelson Nunes

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 12 years ago by Ryan J Ollos

Status: assignednew

comment:9 Changed 5 years ago by Ryan J Ollos

Resolution: wontfix
Status: newclosed

This plugin is deprecated in Trac 1.4 and later. See migration tips on BlackMagicTicketTweaksPlugin page.

Modify Ticket

Change Properties
Set your email in Preferences
Action
as closed The owner will remain Ryan J Ollos.
The resolution will be deleted. Next status will be 'reopened'.

Add Comment


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

 
Note: See TracTickets for help on using tickets.