Edgewall Software
Modify

Opened 9 years ago

Closed 9 years ago

Last modified 8 years ago

#12219 closed enhancement (fixed)

Add a Report model class to report.py

Reported by: Ryan J Ollos Owned by: Ryan J Ollos
Priority: normal Milestone: 1.2
Component: report system Version:
Severity: normal Keywords:
Cc: Branch:
Release Notes:
API Changes:

Extracted a Report model class in trac.ticket.report.

Internal Changes:

Description (last modified by Ryan J Ollos)

The SQL in the ReportModule could be extracted to a Report model class, providing a better API for plugins to make use of.

Attachments (0)

Change History (9)

comment:1 by Ryan J Ollos, 9 years ago

Description: modified (diff)

comment:2 by Ryan J Ollos, 9 years ago

API Changes: modified (diff)

comment:3 by Jun Omae, 9 years ago

2 failures with PostgreSQL.

======================================================================
ERROR: test (trac.wiki.tests.formatter.WikiTestCase)
Test report link with non-digits
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/run/shm/2c9ac20f9f3bf68bd7fa7420be149c6a35745d18/py27-postgres/trac/wiki/tests/formatter.py", line 209, in test
    v = unicode(formatter.generate(**self.generate_opts))
  File "/run/shm/2c9ac20f9f3bf68bd7fa7420be149c6a35745d18/py27-postgres/trac/wiki/formatter.py", line 1545, in generate
    escape_newlines)
  File "/run/shm/2c9ac20f9f3bf68bd7fa7420be149c6a35745d18/py27-postgres/trac/wiki/formatter.py", line 1327, in format
    result = re.sub(self.wikiparser.rules, self.replace, line)
  File "/home/jun66j5/venv/py27-1.1/lib/python2.7/re.py", line 151, in sub
    return _compile(pattern, flags).sub(repl, string, count)
  File "/run/shm/2c9ac20f9f3bf68bd7fa7420be149c6a35745d18/py27-postgres/trac/wiki/formatter.py", line 1245, in replace
    replacement = self.handle_match(fullmatch)
  File "/run/shm/2c9ac20f9f3bf68bd7fa7420be149c6a35745d18/py27-postgres/trac/wiki/formatter.py", line 1241, in handle_match
    return internal_handler(match, fullmatch)
  File "/run/shm/2c9ac20f9f3bf68bd7fa7420be149c6a35745d18/py27-postgres/trac/wiki/formatter.py", line 622, in _shref_formatter
    return self._make_link(ns, target, match, match, fullmatch)
  File "/run/shm/2c9ac20f9f3bf68bd7fa7420be149c6a35745d18/py27-postgres/trac/wiki/formatter.py", line 673, in _make_link
    fullmatch)
  File "/run/shm/2c9ac20f9f3bf68bd7fa7420be149c6a35745d18/py27-postgres/trac/ticket/report.py", line 1001, in _format_link
    Report(self.env, id)
  File "/run/shm/2c9ac20f9f3bf68bd7fa7420be149c6a35745d18/py27-postgres/trac/ticket/report.py", line 124, in __init__
    """, (id,)):
  File "/run/shm/2c9ac20f9f3bf68bd7fa7420be149c6a35745d18/py27-postgres/trac/db/api.py", line 122, in execute
    return db.execute(query, params)
  File "/run/shm/2c9ac20f9f3bf68bd7fa7420be149c6a35745d18/py27-postgres/trac/db/util.py", line 128, in execute
    cursor.execute(query, params if params is not None else [])
  File "/run/shm/2c9ac20f9f3bf68bd7fa7420be149c6a35745d18/py27-postgres/trac/db/util.py", line 61, in execute
    r = self.cursor.execute(sql_escape_percent(sql), args)
DataError: invalid input syntax for integer: "blah"
LINE 3:                     WHERE id='blah'
                                     ^


======================================================================
ERROR: test (trac.wiki.tests.formatter.OneLinerTestCase)
Test report link with non-digits
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/run/shm/2c9ac20f9f3bf68bd7fa7420be149c6a35745d18/py27-postgres/trac/wiki/tests/formatter.py", line 209, in test
    v = unicode(formatter.generate(**self.generate_opts))
  File "/run/shm/2c9ac20f9f3bf68bd7fa7420be149c6a35745d18/py27-postgres/trac/wiki/formatter.py", line 1573, in generate
    shorten)
  File "/run/shm/2c9ac20f9f3bf68bd7fa7420be149c6a35745d18/py27-postgres/trac/wiki/formatter.py", line 1429, in format
    result = re.sub(self.wikiparser.rules, self.replace, result)
  File "/home/jun66j5/venv/py27-1.1/lib/python2.7/re.py", line 151, in sub
    return _compile(pattern, flags).sub(repl, string, count)
  File "/run/shm/2c9ac20f9f3bf68bd7fa7420be149c6a35745d18/py27-postgres/trac/wiki/formatter.py", line 1245, in replace
    replacement = self.handle_match(fullmatch)
  File "/run/shm/2c9ac20f9f3bf68bd7fa7420be149c6a35745d18/py27-postgres/trac/wiki/formatter.py", line 1241, in handle_match
    return internal_handler(match, fullmatch)
  File "/run/shm/2c9ac20f9f3bf68bd7fa7420be149c6a35745d18/py27-postgres/trac/wiki/formatter.py", line 622, in _shref_formatter
    return self._make_link(ns, target, match, match, fullmatch)
  File "/run/shm/2c9ac20f9f3bf68bd7fa7420be149c6a35745d18/py27-postgres/trac/wiki/formatter.py", line 673, in _make_link
    fullmatch)
  File "/run/shm/2c9ac20f9f3bf68bd7fa7420be149c6a35745d18/py27-postgres/trac/ticket/report.py", line 1001, in _format_link
    Report(self.env, id)
  File "/run/shm/2c9ac20f9f3bf68bd7fa7420be149c6a35745d18/py27-postgres/trac/ticket/report.py", line 124, in __init__
    """, (id,)):
  File "/run/shm/2c9ac20f9f3bf68bd7fa7420be149c6a35745d18/py27-postgres/trac/db/api.py", line 122, in execute
    return db.execute(query, params)
  File "/run/shm/2c9ac20f9f3bf68bd7fa7420be149c6a35745d18/py27-postgres/trac/db/util.py", line 128, in execute
    cursor.execute(query, params if params is not None else [])
  File "/run/shm/2c9ac20f9f3bf68bd7fa7420be149c6a35745d18/py27-postgres/trac/db/util.py", line 61, in execute
    r = self.cursor.execute(sql_escape_percent(sql), args)
DataError: invalid input syntax for integer: "blah"
LINE 3:                     WHERE id='blah'
                                     ^


----------------------------------------------------------------------
Ran 2139 tests in 316.904s

FAILED (errors=2)
make: *** [unit-test] Error 1

comment:4 by Ryan J Ollos, 9 years ago

API Changes: modified (diff)
Resolution: fixed
Status: assignedclosed
Type: defectenhancement

Committed to trunk in [14728].

comment:5 by Jun Omae, 9 years ago

I think we should move the Report class to trac.ticket.model…. Milestone class is defined in trac.ticket.model, not trac.ticket.roadmap. Thoughts? Also, it might be good to add realm = 'report' attribute like Ticket.realm.

Last edited 9 years ago by Jun Omae (previous) (diff)

comment:6 by Ryan J Ollos, 9 years ago

comment:7 by Ryan J Ollos, 9 years ago

comment:6 changes committed in [14734].

comment:8 by Ryan J Ollos, 9 years ago

Travis CI test failures unrelated, and reported in #12467.

in reply to:  7 comment:9 by Ryan J Ollos, 8 years ago

Replying to Ryan J Ollos:

comment:6 changes committed in [14734].

Report tests moved from trac.ticket.tests.report to trac.ticket.tests.model in r15596, merged in r15597.

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'.
to The owner will be changed from Ryan J Ollos to the specified user.

Add Comment


E-mail address and name can be saved in the Preferences .
 
Note: See TracTickets for help on using tickets.