Trac Ticket Queries

In addition to reports, Trac provides support for custom ticket queries, used to display lists of tickets meeting a specified set of criteria.

To configure and execute a custom query, switch to the View Tickets module from the navigation bar, and select the Custom Query link.

Filters

When you first go to the query page the default filters will display all open tickets, or if you're logged in it will display open tickets assigned to you. Current filters can be removed by clicking the button to the right with the minus sign on the label. New filters are added from the pulldown list in the bottom-right corner of the filters box. Filters with either a text box or a pulldown menu of options can be added multiple times to perform an or of the criteria.

You can use the fields just below the filters box to group the results based on a field, or display the full description for each ticket.

Once you've edited your filters click the Update button to refresh your results.

Clicking on one of the query results will take you to that ticket. You can navigate through the results by clicking the Next Ticket or Previous Ticket links just below the main menu bar, or click the Back to Query link to return to the query page.

You can safely edit any of the tickets and continue to navigate through the results using the Next/Previous/Back? to Query links after saving your results. When you return to the query any tickets which were edited will be displayed with italicized text. If one of the tickets was edited such that it no longer matches the query criteria the text will also be greyed. Lastly, if a new ticket matching the query criteria has been created, it will be shown in bold.

The query results can be refreshed and cleared of these status indicators by clicking the Update button again.

Saving Queries

While Trac does not yet allow saving a named query and somehow making it available in a navigable list, you can save references to queries in Wiki content, as described below.

You may want to save some queries so that you can come back to them later. You can do this by making a link to the query from any Wiki page.

[query:status=new|assigned|reopened&version=1.0 Active tickets against 1.0]

Which is displayed as:

Active tickets against 1.0

This uses a very simple query language to specify the criteria (see Query Language).

Alternatively, you can copy the query string of a query and paste that into the Wiki link, including the leading ? character:

[query:?status=new&status=assigned&status=reopened&group=owner Assigned tickets by owner]

Which is displayed as:

Assigned tickets by owner

Using the [[TicketQuery]] Macro

The  TicketQuery macro lets you display lists of tickets matching certain criteria anywhere you can use WikiFormatting.

Example:

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

This is displayed as:

No results

Just like the query: wiki links, the parameter of this macro expects a query string formatted according to the rules of the simple ticket query language.

A more compact representation without the ticket summaries is also available:

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

This is displayed as:

No results

Finally if you wish to receive only the number of defects that match the query using the count parameter.

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

This is displayed as:

0

Customizing the table format

You can also customize the columns displayed in the table format (format=table) by using col=<field> - you can specify multiple fields and what order they are displayed by placing pipes (|) between the columns like below:

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

This is displayed as:

Results (1 - 3 of 119)

Ticket Resolution Summary Owner Reporter
#222 invalid Cant seem to install pyyaml on mac os x lion anonymous alex.kikinis7@…
#188 fixed pyyaml 3.09 fails to build with gcc4.6 xi ubuntu@…
#186 invalid Pyyaml using easy_install on Mac OS X xi sudarshan85@…

Full rows

In table format you can also have full rows by using rows=<field> like below:

[[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 119)

Ticket Resolution Summary Owner Reporter
#222 invalid Cant seem to install pyyaml on mac os x lion anonymous alex.kikinis7@…

Reported by alex.kikinis7@…, 5 weeks ago.

description

I downloaded pyyaml form this link http://pyyaml.org/download/pyyaml/PyYAML-3.09.tar.gz on the nltk site. i see it is not the latest version, shouldnt matter right? anywyas followed readme instructions (unclear at best) all they said was type 'python setup.py install' i opened a terminal window and did just that, but receicved the following error python: can't open file 'setup.py': [Errno 2] No such file or directory not sure what to do, not experienced in programming or anything, just getting started

#188 fixed pyyaml 3.09 fails to build with gcc4.6 xi ubuntu@…

Reported by ubuntu@…, 10 months ago.

description

In the next Ubuntu release we will be using gcc4.6. pyyaml fails to build with it. The failure is:

Function `PyCObject_FromVoidPtr' implicitly converted to pointer at ext/_yaml.c:20301 Function `PyCObject_FromVoidPtr' implicitly converted to pointer at ext/_yaml.c:20301

The full build log is available at:

 https://launchpadlibrarian.net/69956046/buildlog_ubuntu-natty-amd64.pyyaml_3.09-5ubuntu2_FAILEDTOBUILD.txt.gz

#186 invalid Pyyaml using easy_install on Mac OS X xi sudarshan85@…

Reported by sudarshan85@…, 11 months ago.

description

Hello, I am trying to install Pyyaml (as part of robot operating system install), however I run into the following error after trying sudo easy_install -U pyyaml:

Searching for pyyaml
Reading http://pypi.python.org/simple/pyyaml/
Reading http://pyyaml.org/wiki/PyYAML
Best match: PyYAML 3.09
Downloading http://pyyaml.org/download/pyyaml/PyYAML-3.09.zip
Processing PyYAML-3.09.zip
Running PyYAML-3.09/setup.py -q bdist_egg --dist-dir /tmp/easy_install-ZJ-Kgs/PyYAML-3.09/egg-dist-tmp-4w-rDE
build/temp.macosx-10.5-i386-2.5/check_libyaml.c:2:18: error: yaml.h: No such file or directory
build/temp.macosx-10.5-i386-2.5/check_libyaml.c: In function ‘main’:
build/temp.macosx-10.5-i386-2.5/check_libyaml.c:5: error: ‘yaml_parser_t’ undeclared (first use in this function)
build/temp.macosx-10.5-i386-2.5/check_libyaml.c:5: error: (Each undeclared identifier is reported only once
build/temp.macosx-10.5-i386-2.5/check_libyaml.c:5: error: for each function it appears in.)
build/temp.macosx-10.5-i386-2.5/check_libyaml.c:5: error: syntax error before ‘parser’
build/temp.macosx-10.5-i386-2.5/check_libyaml.c:6: error: ‘yaml_emitter_t’ undeclared (first use in this function)
build/temp.macosx-10.5-i386-2.5/check_libyaml.c:8: warning: implicit declaration of function ‘yaml_parser_initialize’
build/temp.macosx-10.5-i386-2.5/check_libyaml.c:8: error: ‘parser’ undeclared (first use in this function)
build/temp.macosx-10.5-i386-2.5/check_libyaml.c:9: warning: implicit declaration of function ‘yaml_parser_delete’
build/temp.macosx-10.5-i386-2.5/check_libyaml.c:11: warning: implicit declaration of function ‘yaml_emitter_initialize’
build/temp.macosx-10.5-i386-2.5/check_libyaml.c:11: error: ‘emitter’ undeclared (first use in this function)
build/temp.macosx-10.5-i386-2.5/check_libyaml.c:12: warning: implicit declaration of function ‘yaml_emitter_delete’
build/temp.macosx-10.5-i386-2.5/check_libyaml.c:2:18: error: yaml.h: No such file or directory
build/temp.macosx-10.5-i386-2.5/check_libyaml.c: In function ‘main’:
build/temp.macosx-10.5-i386-2.5/check_libyaml.c:5: error: ‘yaml_parser_t’ undeclared (first use in this function)
build/temp.macosx-10.5-i386-2.5/check_libyaml.c:5: error: (Each undeclared identifier is reported only once
build/temp.macosx-10.5-i386-2.5/check_libyaml.c:5: error: for each function it appears in.)
build/temp.macosx-10.5-i386-2.5/check_libyaml.c:5: error: syntax error before ‘parser’
build/temp.macosx-10.5-i386-2.5/check_libyaml.c:6: error: ‘yaml_emitter_t’ undeclared (first use in this function)
build/temp.macosx-10.5-i386-2.5/check_libyaml.c:8: warning: implicit declaration of function ‘yaml_parser_initialize’
build/temp.macosx-10.5-i386-2.5/check_libyaml.c:8: error: ‘parser’ undeclared (first use in this function)
build/temp.macosx-10.5-i386-2.5/check_libyaml.c:9: warning: implicit declaration of function ‘yaml_parser_delete’
build/temp.macosx-10.5-i386-2.5/check_libyaml.c:11: warning: implicit declaration of function ‘yaml_emitter_initialize’
build/temp.macosx-10.5-i386-2.5/check_libyaml.c:11: error: ‘emitter’ undeclared (first use in this function)
build/temp.macosx-10.5-i386-2.5/check_libyaml.c:12: warning: implicit declaration of function ‘yaml_emitter_delete’
lipo: can't open input file: /var/tmp//cc9LRgKl.out (No such file or directory)
libyaml is not found or a compiler error: forcing --without-libyaml
(if libyaml is installed correctly, you may need to
 specify the option --include-dirs or uncomment and
 modify the parameter include_dirs in setup.cfg)
zip_safe flag not set; analyzing archive contents...
No eggs found in /tmp/easy_install-ZJ-Kgs/PyYAML-3.09/egg-dist-tmp-4w-rDE (setup script problem?)

These are the things that I tried:

1) I installed libyaml using macports and got the same error.

2) I saw this http://pyyaml.org/ticket/94 ticket and tried to upgrade my setuptools using macports (sudo port install py26-setuptools) and got the following error:

--->  Computing dependencies for py26-setuptools
--->  Activating py26-setuptools @0.6c11_1
Error: Target org.macports.activate returned: Image error: /opt/local/Library/Frameworks/Python.framework/Versions/2.6/bin/easy_install already exists and does not belong to a registered port.  Unable to activate port py26-setuptools. Use 'port -f activate py26-setuptools' to force the activation.
Log for py26-setuptools is at: /opt/local/var/macports/logs/_opt_local_var_macports_sources_rsync.macports.org_release_ports_python_py26-setuptools/main.log
Error: Status 1 encountered during processing.
To report a bug, see <http://guide.macports.org/#project.tickets>

When I tried to force activate it as suggested I got this:

--->  Activating py26-setuptools
Warning: File /opt/local/Library/Frameworks/Python.framework/Versions/2.6/bin/easy_install already exists.  Moving to: /opt/local/Library/Frameworks/Python.framework/Versions/2.6/bin/easy_install.mp_1299764382.
Warning: File /opt/local/Library/Frameworks/Python.framework/Versions/2.6/bin/easy_install-2.6 already exists.  Moving to: /opt/local/Library/Frameworks/Python.framework/Versions/2.6/bin/easy_install-2.6.mp_1299764382.
Error: port activate failed: can't create directory "/opt/local/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/site-packages/setuptools-0.6c11-py2.6.egg-info": file already exists

3) Next I got the libyaml source and built it and installed it. After that I tried to install pyyaml again. This time it didnt complain about libyaml not being found, however it still gave me an error. The entire output is quite long, but I got lots of warning about "differ in signedness" along with the following error:

ext/_yaml.c:17348: warning: pointer targets in passing argument 3 of ‘yaml_mapping_start_event_initialize’ differ in signedness
ld warning: in /usr/local/lib/libyaml.dylib, file is not of required architecture
zip_safe flag not set; analyzing archive contents...
No eggs found in /tmp/easy_install-DpLGbQ/PyYAML-3.09/egg-dist-tmp-NONW0s (setup script problem?)

Those are the last few lines of the output. I don't know how to solve this problem, as I am not familiar with python's setuptools.

4) Finally, I got the pyyaml-3.09 source and installed as per the instructions. It installed without problems,

running install
running build
running build_py
running build_ext
running install_lib
running install_egg_info
Removing /opt/local/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/site-packages/PyYAML-3.09-py2.6.egg-info
Writing /opt/local/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/site-packages/PyYAML-3.09-py2.6.egg-info

However, as the next step in the ROS install, I ran this command as described in this website [rosinstall ~/ros " http://packages.ros.org/cgi-bin/gen_rosinstall.py?rosdistro=diamondback&variant=ros-full&overlay=no"] and I got the following error:

Traceback (most recent call last):
  File "/usr/local/bin/rosinstall", line 5, in <module>
    pkg_resources.run_script('rosinstall==0.5.16', 'rosinstall')
  File "/System/Library/Frameworks/Python.framework/Versions/2.5/Extras/lib/python/pkg_resources.py", line 442, in run_script
    self.require(requires)[0].run_script(script_name, ns)
  File "/System/Library/Frameworks/Python.framework/Versions/2.5/Extras/lib/python/pkg_resources.py", line 1167, in run_script
    exec script_code in namespace, namespace
  File "/usr/local/bin/rosinstall", line 23, in <module>
    
ImportError: No module named yaml

which seems to indicate that pyyaml (or yaml?) is still not installed (or its installed in a place where this command is not looking). Right now, I am out of options, I don't know what else to try.

Any help on this is greatly appreciated.

Thanks,

S.

Query Language

query: TracLinks and the [[TicketQuery]] macro both use a mini “query language” for specifying query filters. Basically, the filters are separated by ampersands (&). Each filter then consists of the ticket field name, an operator, and one or more values. More than one value are separated by a pipe (|), meaning that the filter matches any of the values.

The available operators are:

= the field content exactly matches the one of the values
~= the field content contains one or more of the values
^= the field content starts with one of the values
$= the field content ends with one of the values

All of these operators can also be negated:

!= the field content matches none of the values
!~= the field content does not contain any of the values
!^= the field content does not start with any of the values
!$= the field content does not end with any of the values

See also: TracTickets, TracReports, TracGuide