Edgewall Software

This page documents the 1.4 (latest stable) release. Documentation for other releases can be found here.

TicketQuery Wiki Macro

The TicketQuery macro lets you display ticket information anywhere that accepts WikiFormatting. The query language used by the [[TicketQuery]] macro is described in the TracQuery page.

Usage

[[TicketQuery]]

Wiki macro listing tickets that match certain criteria.

This macro accepts a comma-separated list of keyed parameters, in the form "key=value".

If the key is the name of a field, the value must use the syntax of a filter specifier as defined in TracQuery#QueryLanguage. Note that this is not the same as the simplified URL syntax used for query: links starting with a ? character. Commas (,) can be included in field values by escaping them with a backslash (\).

Groups of field constraints to be OR-ed together can be separated by a literal or argument.

In addition to filters, several other named parameters can be used to control how the results are presented. All of them are optional.

The format parameter determines how the list of tickets is presented:

  • list — the default presentation is to list the ticket ID next to the summary, with each ticket on a separate line.
  • compact — the tickets are presented as a comma-separated list of ticket IDs.
  • count — only the count of matching tickets is displayed
  • rawcount — only the count of matching tickets is displayed, not even with a link to the corresponding query (since 1.1.1)
  • table — a view similar to the custom query view (but without the controls)
  • progress — a view similar to the milestone progress bars

The max parameter can be used to limit the number of tickets shown (defaults to 0, i.e. no maximum).

The order parameter sets the field used for ordering tickets (defaults to id).

The desc parameter indicates whether the order of the tickets should be reversed (defaults to false).

The group parameter sets the field used for grouping tickets (defaults to not being set).

The groupdesc parameter indicates whether the natural display order of the groups should be reversed (defaults to false).

The verbose parameter can be set to a true value in order to get the description for the listed tickets. For table format only. deprecated in favor of the rows parameter

The rows parameter can be used to specify which field(s) should be viewed as a row, e.g. rows=description|summary

The col parameter can be used to specify which fields should be viewed as columns. For table format only.

For compatibility with Trac 0.10, if there's a last positional parameter given to the macro, it will be used to specify the format. Also, using "&" as a field separator still works (except for order) but is deprecated.

Examples

Example Result Macro
Number of Triage tickets: 22 [[TicketQuery(status=new&milestone=,count)]]
Number of new tickets: 1061 [[TicketQuery(status=new,count)]]
Number of reopened tickets: 3 [[TicketQuery(status=reopened,count)]]
Number of assigned tickets: 18 [[TicketQuery(status=assigned,count)]]
Number of invalid tickets: 1515 [[TicketQuery(status=closed,resolution=invalid,count)]]
Number of worksforme tickets: 1416 [[TicketQuery(status=closed,resolution=worksforme,count)]]
Number of duplicate tickets: 2188 [[TicketQuery(status=closed,resolution=duplicate,count)]]
Number of wontfix tickets: 992 [[TicketQuery(status=closed,resolution=wontfix,count)]]
Number of fixed tickets: 4538 [[TicketQuery(status=closed,resolution=fixed,count)]]
Number of untriaged tickets (milestone unset): 24 [[TicketQuery(status!=closed,milestone=,count)]]
Total number of tickets: 12318 [[TicketQuery(count)]]
Number of tickets reported or owned by current user: 1847 [[TicketQuery(reporter=$USER,or,owner=$USER,count)]]
Number of tickets created this month: 0 [[TicketQuery(created=thismonth..,count)]]
Number of closed Firefox tickets: 13 [[TicketQuery(status=closed,keywords~=firefox,count)]]
Number of closed Opera tickets: 12 [[TicketQuery(status=closed,keywords~=opera,count)]]
Number of closed tickets affecting Firefox and Opera: 1 [[TicketQuery(status=closed,keywords~=firefox opera,count)]]
Number of closed tickets affecting Firefox or Opera: 24 [[TicketQuery(status=closed,keywords~=firefox|opera,count)]]
Number of tickets that affect Firefox or are closed and affect Opera: 25 [[TicketQuery(status=closed,keywords~=opera,or,keywords~=firefox,count)]]
Number of closed Firefox tickets that don't affect Opera: 1 [[TicketQuery(status=closed,keywords~=firefox -opera,count)]]
Last 3 modified tickets: #71, #13333, #13607 [[TicketQuery(max=3,order=modified,desc=1,compact)]]

Details of ticket #1:

[[TicketQuery(id=1,col=id|owner|reporter,rows=summary,table)]]

Ticket Owner Reporter
#1 anonymous
Summary Add a new project summary module.

Format: list

[[TicketQuery(version=0.6|0.7&resolution=duplicate)]]

This is displayed as:

#181
Wiki preview injects new lines
#204
request for colour legend (or something similar) for ticket groups in reports
#226
Ticket Dependencies
#239
Link to diff of specifik wiki change instead of the page itself
#351
All ticket modifications should be tracked in timeline
#413
Installing on Windows, drive other than C:
#450
Diffviewer should try to convert the text into utf-8.
#475
merging of similar tickets
#519
Python process sometimes hangs on Windows Server 2003
#529
IE 5-6 over HTTPS broken downloads

[[TicketQuery(id=123)]]

This is displayed as:

#123
No SQL error display

Format: compact

[[TicketQuery(version=0.6|0.7&resolution=duplicate, compact)]]

This is displayed as:

#181, #204, #226, #239, #351, #413, #450, #475, #519, #529

Format: count

[[TicketQuery(version=0.6|0.7&resolution=duplicate, count)]]

This is displayed as:

10

Format: progress

[[TicketQuery(milestone=0.12.8&group=type,format=progress)]]

This is displayed as:

defect

5 / 5

enhancement

2 / 2

Format: table

You can choose the columns displayed in the table format (format=table) using col=<field>. You can specify multiple fields and the order they are displayed in by placing pipes (|) between the columns:

[[TicketQuery(max=3,status=closed,order=id,desc=1,format=table,col=resolution|summary|owner|reporter)]]

This is displayed as:

Full rows

In table format you can specify full rows using rows=<field>:

[[TicketQuery(max=3,status=closed,order=id,desc=1,format=table,col=resolution|summary|owner|reporter,rows=description)]]

This is displayed as:

Results (1 - 3 of 11236)

1 2 3 4 5 6 7 8 9 10 11
Ticket Resolution Summary Owner Reporter
#13605 fixed 2 test failures with Python 3.11 on Windows (part of #13402) Jun Omae Jun Omae
Description

I got 2 failures with Python 3.11 on Windows.

Python: /c/Users/runneradmin/AppData/Local/venv/Scripts/python 

  Package        Version
  -----------------------------------------------------------------------------------------------
  Python       : 3.11.1 (tags/v3.11.1:a7a450f, Dec  6 2022, 19:58:39) [MSC v.1934 64 bit (AMD64)]
  Setuptools   : 65.6.3
  Pip          : 22.3.1
  Wheel        : not installed
  Jinja2       : 3.1.2
  Babel        : not installed
  sqlite3      : 2.6.0 (3.39.4)
  PySqlite3    : not installed
  PyMySQL      : not installed
  Psycopg2     : not installed
  SVN bindings : not installed
  Mercurial    : not installed
  Pygments     : not installed
  Textile      : not installed
  Pytz         : not installed
  Docutils     : not installed
  Selenium     : 4.7.2
  PyTidyLib    : 0.3.2 (5.9.14 C:\Users\runneradmin\AppData\Local\venv\Scripts\tidy.dll)
  LXML         : not installed
  coverage     : not installed

Variables:
  PATH=/mingw64/bin:/usr/bin:/c/Users/runneradmin/bin:/c/Users/runneradmin/AppData/Local/venv/Scripts:/c/Users/runneradmin/AppData/Local/venv/Scripts/Scripts:/c/Users/runneradmin/AppData/Local/venv/Scripts:/c/Program Files/PowerShell/7:/c/Users/runneradmin/AppData/Roaming/Python/Python311/Scripts:/c/hostedtoolcache/windows/Python/3.11.1/x64/Scripts:/c/hostedtoolcache/windows/Python/3.11.1/x64:/c/Program Files/MongoDB/Server/5.0/bin:/c/aliyun-cli:/c/vcpkg:/c/Program Files (x86)/NSIS:/c/tools/zstd:/c/Program Files/Mercurial:/c/hostedtoolcache/windows/stack/2.9.1/x64:/c/cabal/bin:/c/ghcup/bin:/c/tools/ghc-9.4.2/bin:/c/Program Files/dotnet:/c/mysql/bin:/c/Program Files/R/R-4.2.2/bin/x64:/c/SeleniumWebDrivers/GeckoDriver:/c/Program Files (x86)/sbt/bin:/c/Program Files (x86)/GitHub CLI:/bin:/c/Program Files (x86)/pipx_bin:/c/npm/prefix:/c/hostedtoolcache/windows/go/1.17.13/x64/bin:/c/hostedtoolcache/windows/Python/3.9.13/x64/Scripts:/c/hostedtoolcache/windows/Python/3.9.13/x64:/c/hostedtoolcache/windows/Ruby/3.0.5/x64/bin:/c/tools/kotlinc/bin:/c/hostedtoolcache/windows/Java_Temurin-Hotspot_jdk/8.0.352-8/x64/bin:/c/Program Files/ImageMagick-7.1.0-Q16-HDRI:/c/Program Files (x86)/Microsoft SDKs/Azure/CLI2/wbin:/c/ProgramData/kind:/c/Program Files/Microsoft/jdk-11.0.12.7-hotspot/bin:/c/Windows/system32:/c/Windows:/c/Windows/System32/Wbem:/c/Windows/System32/WindowsPowerShell/v1.0:/c/Windows/System32/OpenSSH:/c/Program Files/dotnet:/c/ProgramData/Chocolatey/bin:/c/Program Files/PowerShell/7:/c/Program Files/Microsoft/Web Platform Installer:/c/Program Files/Microsoft SQL Server/Client SDK/ODBC/170/Tools/Binn:/c/Program Files/Microsoft SQL Server/150/Tools/Binn:/c/Program Files/OpenSSL/bin:/c/Strawberry/c/bin:/c/Strawberry/perl/site/bin:/c/Strawberry/perl/bin:/c/ProgramData/chocolatey/lib/pulumi/tools/Pulumi/bin:/c/Program Files/TortoiseSVN/bin:/c/Program Files/CMake/bin:/c/ProgramData/chocolatey/lib/maven/apache-maven-3.8.6/bin:/c/Program Files/Microsoft Service Fabric/bin/Fabric/Fabric.Code:/c/Program Files/Microsoft SDKs/Service Fabric/Tools/ServiceFabricLocalClusterManager:/c/Program Files/nodejs:/cmd:/mingw64/bin:/usr/bin:/c/Program Files/GitHub CLI:/c/tools/php:/c/Program Files (x86)/sbt/bin:/c/SeleniumWebDrivers/ChromeDriver:/c/SeleniumWebDrivers/EdgeDriver:/c/Program Files/Amazon/AWSCLIV2:/c/Program Files/Amazon/SessionManagerPlugin/bin:/c/Program Files/Amazon/AWSSAMCLI/bin:/c/Program Files/Microsoft SQL Server/130/Tools/Binn:/c/Program Files/LLVM/bin:/c/Users/runneradmin/.dotnet/tools:/c/Users/runneradmin/.cargo/bin:/c/Users/runneradmin/AppData/Local/Microsoft/WindowsApps
  PYTHONPATH=.
  TRAC_TEST_DB_URI=
  server-options= -p 8000  -r -e 

External dependencies:
  Git version: git version 2.39.0.windows.1
  Subversion version: 1.14.2

...

======================================================================
ERROR: test_database_version (trac.tests.env.EnvironmentWithoutDataTestCase.test_database_version)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "C:\hostedtoolcache\windows\Python\3.11.1\x64\Lib\shutil.py", line 620, in _rmtree_unsafe
    os.unlink(fullname)
PermissionError: [WinError 32] The process cannot access the file because it is being used by another process: 'c:\\users\\runneradmin\\appdata\\local\\temp\\trac-testdir-uqx7slhr\\db\\trac.db'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "D:\a\trac\trac\trac\tests\env.py", line 47, in tearDown
    rmtree(self.env.path)
  File "D:\a\trac\trac\trac\test.py", line 549, in rmtree
    shutil.rmtree(path, onerror=onerror)
  File "C:\hostedtoolcache\windows\Python\3.11.1\x64\Lib\shutil.py", line 759, in rmtree
    return _rmtree_unsafe(path, onerror)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\hostedtoolcache\windows\Python\3.11.1\x64\Lib\shutil.py", line 617, in _rmtree_unsafe
    _rmtree_unsafe(fullname, onerror)
  File "C:\hostedtoolcache\windows\Python\3.11.1\x64\Lib\shutil.py", line 622, in _rmtree_unsafe
    onerror(os.unlink, fullname, sys.exc_info())
  File "D:\a\trac\trac\trac\test.py", line 544, in onerror
    onerror(function, path, excinfo, retry + 1)
  File "D:\a\trac\trac\trac\test.py", line 544, in onerror
    onerror(function, path, excinfo, retry + 1)
  File "D:\a\trac\trac\trac\test.py", line 544, in onerror
    onerror(function, path, excinfo, retry + 1)
  [Previous line repeated 7 more times]
  File "D:\a\trac\trac\trac\test.py", line 536, in onerror
    function(path)
PermissionError: [WinError 32] The process cannot access the file because it is being used by another process: 'c:\\users\\runneradmin\\appdata\\local\\temp\\trac-testdir-uqx7slhr\\db\\trac.db'

======================================================================
ERROR: test_invalid_log_type_raises_exception (trac.tests.env.EnvironmentTestCase.test_invalid_log_type_raises_exception)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "C:\hostedtoolcache\windows\Python\3.11.1\x64\Lib\shutil.py", line 620, in _rmtree_unsafe
    os.unlink(fullname)
PermissionError: [WinError 32] The process cannot access the file because it is being used by another process: 'c:\\users\\runneradmin\\appdata\\local\\temp\\trac-testdir-1imzguf5\\db\\trac.db'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "D:\a\trac\trac\trac\tests\env.py", line 106, in tearDown
    rmtree(self.env.path)
  File "D:\a\trac\trac\trac\test.py", line 549, in rmtree
    shutil.rmtree(path, onerror=onerror)
  File "C:\hostedtoolcache\windows\Python\3.11.1\x64\Lib\shutil.py", line 759, in rmtree
    return _rmtree_unsafe(path, onerror)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\hostedtoolcache\windows\Python\3.11.1\x64\Lib\shutil.py", line 617, in _rmtree_unsafe
    _rmtree_unsafe(fullname, onerror)
  File "C:\hostedtoolcache\windows\Python\3.11.1\x64\Lib\shutil.py", line 622, in _rmtree_unsafe
    onerror(os.unlink, fullname, sys.exc_info())
  File "D:\a\trac\trac\trac\test.py", line 544, in onerror
    onerror(function, path, excinfo, retry + 1)
  File "D:\a\trac\trac\trac\test.py", line 544, in onerror
    onerror(function, path, excinfo, retry + 1)
  File "D:\a\trac\trac\trac\test.py", line 544, in onerror
    onerror(function, path, excinfo, retry + 1)
  [Previous line repeated 7 more times]
  File "D:\a\trac\trac\trac\test.py", line 536, in onerror
    function(path)
PermissionError: [WinError 32] The process cannot access the file because it is being used by another process: 'c:\\users\\runneradmin\\appdata\\local\\temp\\trac-testdir-1imzguf5\\db\\trac.db'

----------------------------------------------------------------------
Ran 2465 tests in 261.398s

FAILED (errors=2, skipped=9)
#13604 fixed Python 3.12.0b1: datetime.utcfromtimestamp() is deprecated and scheduled for removal in a future version Jun Omae Jun Omae
Description

The following is warned on calling parse_date with Python 3.12.

trac/util/datefmt.py:646: DeprecationWarning: datetime.utcfromtimestamp() is deprecated and scheduled for removal in a future version. Use timezone-aware objects to represent datetimes in UTC: datetime.fromtimestamp(timestamp, datetime.UTC).
  datetime.utcfromtimestamp(ts)

See also: https://docs.python.org/3.12/library/datetime.html?highlight=deprecated#datetime.datetime.utcfromtimestamp

Patch:

  • trac/util/datefmt.py

    diff --git a/trac/util/datefmt.py b/trac/util/datefmt.py
    index 80b574feb..d407b86ba 100644
    a b def parse_date(text, tzinfo=None, locale=None, hint='date'):  
    639639                    date=text, hint=formatted_hint, isohint=isohint)
    640640        raise TracError(msg, _('Invalid Date'))
    641641    # Make sure we can convert it to a timestamp and back -
    642     # utcfromtimestamp() may raise OverflowError and OSError if out of
     642    # fromtimestamp(..., utc) may raise OverflowError and OSError if out of
    643643    # range by platform C gmtime() and gmtime() failure
    644644    ts = to_timestamp(dt)
    645645    try:
    646         datetime.utcfromtimestamp(ts)
     646        datetime.fromtimestamp(ts, utc)
    647647    except (ValueError, OverflowError, OSError):
    648648        raise TracError(_('The date "%(date)s" is outside valid range. '
    649649                          'Try a date closer to present time.', date=text),
#13603 fixed Python 3.12.0b1: shutil.rmtree: DeprecationWarning: onerror argument is deprecated, use onexc instead Jun Omae Jun Omae
Description

The following is warned on invoking shutil.rmtree(onerror=...) with Python 3.12.

trac/test.py:555: DeprecationWarning: onerror argument is deprecated, use onexc instead
  shutil.rmtree(path, onerror=onerror)

See also: https://docs.python.org/3.12/library/shutil.html?highlight=onexc#shutil.rmtree

Patch:

  • trac/test.py

    index e6102be75..197b63315 100755
    a b def locate(fn):  
    527527    return None
    528528
    529529
     530if hasattr(inspect, 'getfullargspec'):  # Python 3.11+
     531    _rmtree_argspec = inspect.getfullargspec(shutil.rmtree)
     532    # onexc is added in Python 3.12 and onerror is deprecated
     533    _rmtree_has_onexc = 'onexc' in getattr(_rmtree_argspec, 'kwonlyargs', [])
     534    del _rmtree_argspec
     535else:
     536    _rmtree_has_onexc = False
     537
     538
    530539def rmtree(path):
    531540    def onerror(function, path, excinfo, retry=1):
    532541        # `os.unlink` and `os.remove` fail for a readonly file on Windows.
    def rmtree(path):  
    552561        # Use unicode characters in order to allow non-ansi characters
    553562        # on Windows.
    554563        path = str(path, sys.getfilesystemencoding())
    555     shutil.rmtree(path, onerror=onerror)
     564    kwargs = {'onexc' if _rmtree_has_onexc else 'onerror': onerror}
     565    shutil.rmtree(path, **kwargs)
    556566
    557567
    558568INCLUDE_FUNCTIONAL_TESTS = True
1 2 3 4 5 6 7 8 9 10 11


See also: TracQuery, TracTickets, TracReports

Last modified 15 months ago Last modified on Mar 6, 2022, 8:38:39 AM
Note: See TracWiki for help on using the wiki.