incubator-bloodhound-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From g..@apache.org
Subject svn commit: r1307967 [1/2] - in /incubator/bloodhound/trunk/bloodhound_dashboard/bhdashboard: tests/__init__.py tests/test_report.py util.py web_ui.py widgets/report.py widgets/templates/widget_grid.html
Date Sun, 01 Apr 2012 00:54:23 GMT
Author: gjm
Date: Sun Apr  1 00:54:22 2012
New Revision: 1307967

URL: http://svn.apache.org/viewvc?rev=1307967&view=rev
Log:
Dashboard code import: BH_Dashboard: Reusing 'ReportModule._render_view'. Implemented test cases ok for Trac=0.11

Modified:
    incubator/bloodhound/trunk/bloodhound_dashboard/bhdashboard/tests/__init__.py
    incubator/bloodhound/trunk/bloodhound_dashboard/bhdashboard/tests/test_report.py
    incubator/bloodhound/trunk/bloodhound_dashboard/bhdashboard/util.py
    incubator/bloodhound/trunk/bloodhound_dashboard/bhdashboard/web_ui.py
    incubator/bloodhound/trunk/bloodhound_dashboard/bhdashboard/widgets/report.py
    incubator/bloodhound/trunk/bloodhound_dashboard/bhdashboard/widgets/templates/widget_grid.html

Modified: incubator/bloodhound/trunk/bloodhound_dashboard/bhdashboard/tests/__init__.py
URL: http://svn.apache.org/viewvc/incubator/bloodhound/trunk/bloodhound_dashboard/bhdashboard/tests/__init__.py?rev=1307967&r1=1307966&r2=1307967&view=diff
==============================================================================
--- incubator/bloodhound/trunk/bloodhound_dashboard/bhdashboard/tests/__init__.py (original)
+++ incubator/bloodhound/trunk/bloodhound_dashboard/bhdashboard/tests/__init__.py Sun Apr  1 00:54:22 2012
@@ -23,28 +23,15 @@ The test suites have been run using Trac
 
 __metaclass__ = type
 
+import sys
+
 from trac.core import ComponentMeta
 from trac.db.api import _parse_db_str, DatabaseManager
 from trac.mimeview.api import Context
 from trac.test import EnvironmentStub
 from trac.util.compat import set
 
-from pkg_resources import get_distribution
-import sys
-
-#------------------------------------------------------
-#    Context information
-#------------------------------------------------------
-
-trac_version = tuple(int(i) for i in get_distribution('Trac').parsed_version \
-                            if i.startswith('0'))
-
-# The exact moments (versions) where some things started to change
-# in such a manner that break previous test code
-
-trac_tags = (
-        (0, 13), # TODO: Find the exact version ( Trac=0.12 ? )
-    )
+from bhdashboard.util import trac_version, trac_tags
 
 #------------------------------------------------------
 #    Trac environments used for testing purposes

Modified: incubator/bloodhound/trunk/bloodhound_dashboard/bhdashboard/tests/test_report.py
URL: http://svn.apache.org/viewvc/incubator/bloodhound/trunk/bloodhound_dashboard/bhdashboard/tests/test_report.py?rev=1307967&r1=1307966&r2=1307967&view=diff
==============================================================================
--- incubator/bloodhound/trunk/bloodhound_dashboard/bhdashboard/tests/test_report.py (original)
+++ incubator/bloodhound/trunk/bloodhound_dashboard/bhdashboard/tests/test_report.py Sun Apr  1 00:54:22 2012
@@ -157,9 +157,10 @@ __test__ = {
       {'id': {'desc': 'Report number',
                   'required': True,
                   'type': <type 'int'>},
-       'limit': {'default': 0,
-                  'desc': 'Number of results to retrieve',
-                  'type': <type 'int'>}}
+       'page': {'default': 1,
+                  'desc': 'Retrieve results in given page.',
+                  'type': <type 'int'>},
+       'user': {'desc': 'Render the report for a given user.'}}
       """,
     '|TicketReport: Render My Tickets report' : r"""
 
@@ -215,7 +216,73 @@ __test__ = {
       ...     'args' : {'id' : 7}
       ...   }))
       ...
-      ('widget_grid.html', {'data': [], 'title': <Element "a">}, <...Context >)
+      ('widget_grid.html',
+       {'data': {'action': 'view',
+                 'args': {'USER': 'anonymous'},
+                 'context': <...Context <Resource u'report:7'>>,
+                 'description': u'\nThis report demonstrates the use of the automatically set \nUSER dynamic variable, replaced with the username of the\nlogged in user when executed.\n',
+                 'email_map': {},
+                 'header_groups': [[{'asc': False,
+                                     'col': u'__color__',
+                                     'hidden': True,
+                                     'title': u'Color'},
+                                    {'asc': False,
+                                     'col': u'__group__',
+                                     'hidden': True,
+                                     'title': u'Group'},
+                                    {'asc': False,
+                                     'col': u'ticket',
+                                     'hidden': False,
+                                     'title': u'Ticket'},
+                                    {'asc': False,
+                                     'col': u'summary',
+                                     'hidden': False,
+                                     'title': u'Summary'},
+                                    {'asc': False,
+                                     'col': u'component',
+                                     'hidden': False,
+                                     'title': u'Component'},
+                                    {'asc': False,
+                                     'col': u'version',
+                                     'hidden': False,
+                                     'title': u'Version'},
+                                    {'asc': False,
+                                     'col': u'milestone',
+                                     'hidden': False,
+                                     'title': u'Milestone'},
+                                    {'asc': False,
+                                     'col': u'type',
+                                     'hidden': False,
+                                     'title': u'Type'},
+                                    {'asc': False,
+                                     'col': u'priority',
+                                     'hidden': False,
+                                     'title': u'Priority'},
+                                    {'asc': False,
+                                     'col': u'created',
+                                     'hidden': False,
+                                     'title': u'Created'},
+                                    {'asc': False,
+                                     'col': u'_changetime',
+                                     'hidden': True,
+                                     'title': u'Changetime'},
+                                    {'asc': False,
+                                     'col': u'_description',
+                                     'hidden': True,
+                                     'title': u'Description'},
+                                    {'asc': False,
+                                     'col': u'_reporter',
+                                     'hidden': True,
+                                     'title': u'Reporter'}]],
+                 'message': None,
+                 'numrows': 0,
+                 'paginator': <trac.util.presentation.Paginator object at ...>,
+                 'report': {'id': 7, 'resource': <Resource u'report:7'>},
+                 'row_groups': [],
+                 'sorting_enabled': False,
+                 'title': u'{7} My Tickets'},
+        'title': <Element "a">},
+       <...Context <Resource u'report:7'>>)
 
       >>> template, data, rptctx = widget.render_widget('TicketReport', auth_ctx, {
       ...     'args' : {'id' : 7}
@@ -224,63 +291,341 @@ __test__ = {
       >>> data = data['data']
       >>> template
       'widget_grid.html'
-      >>> rptctx is auth_ctx
+      >>> rptctx.parent is auth_ctx
       True
 
       In Trac=0.13 (0.12 ?) My Tickets report adds another group
       So perform common check in here ...
 
-      >>> pprint([x for x in data if x.get('__group__') != 'Reported'])
-      [{u'__color__': u'3',
-        u'__group__': u'Accepted',
-        u'_changetime': ...,
-        u'_description': u'Description 1',
-        u'_reporter': u'murphy',
-        u'component': u'component1',
-        u'created': ...,
-        u'milestone': u'milestone1',
-        u'priority': u'major',
-        u'summary': u'Ticket 1',
-        u'ticket': 1,
-        u'type': u'defect',
-        u'version': u'1.0'},
-       {u'__color__': u'3',
-        u'__group__': u'Accepted',
-        u'_changetime': ...,
-        u'_description': u'Description 2',
-        u'_reporter': u'murphy',
-        u'component': None,
-        u'created': ...,
-        u'milestone': u'milestone4',
-        u'priority': u'major',
-        u'summary': u'Ticket 2',
-        u'ticket': 2,
-        u'type': u'task',
-        u'version': None},
-       {u'__color__': u'4',
-        u'__group__': u'Owned',
-        u'_changetime': ...,
-        u'_description': u'Description 5',
-        u'_reporter': u'murphy',
-        u'component': None,
-        u'created': ...,
-        u'milestone': u'milestone3',
-        u'priority': u'minor',
-        u'summary': u'Ticket 5',
-        u'ticket': 5,
-        u'type': u'task',
-        u'version': u'2.0'}]
+      >>> reported_tickets = None
+      >>> for x in data['row_groups']:
+      ...   if x[0] == 'Reported':
+      ...     reported_tickets = x
+      ...     break
+      ...
+      >>> if reported_tickets:
+      ...   data['row_groups'].remove(reported_tickets)
+      ...
+      >>> pprint(data)
+      {'action': 'view',
+       'args': {'USER': 'murphy'},
+       'context': <Context <Resource u'report:7'>>,
+       'description': u'\nThis report demonstrates the use of the automatically set \nUSER dynamic variable, replaced with the username of the\nlogged in user when executed.\n',
+       'email_map': {},
+       'header_groups': [[{'asc': False,
+                           'col': u'__color__',
+                           'hidden': True,
+                           'title': u'Color'},
+                          {'asc': False,
+                           'col': u'__group__',
+                           'hidden': True,
+                           'title': u'Group'},
+                          {'asc': False,
+                           'col': u'ticket',
+                           'hidden': False,
+                           'title': u'Ticket'},
+                          {'asc': False,
+                           'col': u'summary',
+                           'hidden': False,
+                           'title': u'Summary'},
+                          {'asc': False,
+                           'col': u'component',
+                           'hidden': False,
+                           'title': u'Component'},
+                          {'asc': False,
+                           'col': u'version',
+                           'hidden': False,
+                           'title': u'Version'},
+                          {'asc': False,
+                           'col': u'milestone',
+                           'hidden': False,
+                           'title': u'Milestone'},
+                          {'asc': False,
+                           'col': u'type',
+                           'hidden': False,
+                           'title': u'Type'},
+                          {'asc': False,
+                           'col': u'priority',
+                           'hidden': False,
+                           'title': u'Priority'},
+                          {'asc': False,
+                           'col': u'created',
+                           'hidden': False,
+                           'title': u'Created'},
+                          {'asc': False,
+                           'col': u'_changetime',
+                           'hidden': True,
+                           'title': u'Changetime'},
+                          {'asc': False,
+                           'col': u'_description',
+                           'hidden': True,
+                           'title': u'Description'},
+                          {'asc': False,
+                           'col': u'_reporter',
+                           'hidden': True,
+                           'title': u'Reporter'}]],
+       'message': None,
+       'numrows': 3,
+       'paginator': <trac.util.presentation.Paginator object at ...>,
+       'report': {'id': 7, 'resource': <Resource u'report:7'>},
+       'row_groups': [(u'Accepted',
+                       [{u'__color__': u'3',
+                         '__idx__': 0,
+                         'cell_groups': [[{'header': {'asc': False,
+                                                      'col': u'__color__',
+                                                      'hidden': True,
+                                                      'title': u'Color'},
+                                           'index': 0,
+                                           'value': u'3'},
+                                          {'header': {'asc': False,
+                                                      'col': u'__group__',
+                                                      'hidden': True,
+                                                      'title': u'Group'},
+                                           'index': 1,
+                                           'value': u'Accepted'},
+                                          {'header': {'asc': False,
+                                                      'col': u'ticket',
+                                                      'hidden': False,
+                                                      'title': u'Ticket'},
+                                           'index': 2,
+                                           'value': u'1'},
+                                          {'header': {'asc': False,
+                                                      'col': u'summary',
+                                                      'hidden': False,
+                                                      'title': u'Summary'},
+                                           'index': 3,
+                                           'value': u'Ticket 1'},
+                                          {'header': {'asc': False,
+                                                      'col': u'component',
+                                                      'hidden': False,
+                                                      'title': u'Component'},
+                                           'index': 4,
+                                           'value': u'component1'},
+                                          {'header': {'asc': False,
+                                                      'col': u'version',
+                                                      'hidden': False,
+                                                      'title': u'Version'},
+                                           'index': 5,
+                                           'value': u'1.0'},
+                                          {'header': {'asc': False,
+                                                      'col': u'milestone',
+                                                      'hidden': False,
+                                                      'title': u'Milestone'},
+                                           'index': 6,
+                                           'value': u'milestone1'},
+                                          {'header': {'asc': False,
+                                                      'col': u'type',
+                                                      'hidden': False,
+                                                      'title': u'Type'},
+                                           'index': 7,
+                                           'value': u'defect'},
+                                          {'header': {'asc': False,
+                                                      'col': u'priority',
+                                                      'hidden': False,
+                                                      'title': u'Priority'},
+                                           'index': 8,
+                                           'value': u'major'},
+                                          {'header': {'asc': False,
+                                                      'col': u'created',
+                                                      'hidden': False,
+                                                      'title': u'Created'},
+                                           'index': 9,
+                                           'value': u'...'},
+                                          {'header': {'asc': False,
+                                                      'col': u'_changetime',
+                                                      'hidden': True,
+                                                      'title': u'Changetime'},
+                                           'index': 10,
+                                           'value': u'...'},
+                                          {'header': {'asc': False,
+                                                      'col': u'_description',
+                                                      'hidden': True,
+                                                      'title': u'Description'},
+                                           'index': 11,
+                                           'value': u'Description 1'},
+                                          {'header': {'asc': False,
+                                                      'col': u'_reporter',
+                                                      'hidden': True,
+                                                      'title': u'Reporter'},
+                                           'index': 12,
+                                           'value': u'murphy'}]],
+                         'id': u'1',
+                         'resource': <Resource u'ticket:1'>},
+                        {u'__color__': u'3',
+                         '__idx__': 1,
+                         'cell_groups': [[{'header': {'asc': False,
+                                                      'col': u'__color__',
+                                                      'hidden': True,
+                                                      'title': u'Color'},
+                                           'index': 0,
+                                           'value': u'3'},
+                                          {'header': {'asc': False,
+                                                      'col': u'__group__',
+                                                      'hidden': True,
+                                                      'title': u'Group'},
+                                           'index': 1,
+                                           'value': u'Accepted'},
+                                          {'header': {'asc': False,
+                                                      'col': u'ticket',
+                                                      'hidden': False,
+                                                      'title': u'Ticket'},
+                                           'index': 2,
+                                           'value': u'2'},
+                                          {'header': {'asc': False,
+                                                      'col': u'summary',
+                                                      'hidden': False,
+                                                      'title': u'Summary'},
+                                           'index': 3,
+                                           'value': u'Ticket 2'},
+                                          {'header': {'asc': False,
+                                                      'col': u'component',
+                                                      'hidden': False,
+                                                      'title': u'Component'},
+                                           'index': 4,
+                                           'value': ''},
+                                          {'header': {'asc': False,
+                                                      'col': u'version',
+                                                      'hidden': False,
+                                                      'title': u'Version'},
+                                           'index': 5,
+                                           'value': ''},
+                                          {'header': {'asc': False,
+                                                      'col': u'milestone',
+                                                      'hidden': False,
+                                                      'title': u'Milestone'},
+                                           'index': 6,
+                                           'value': u'milestone4'},
+                                          {'header': {'asc': False,
+                                                      'col': u'type',
+                                                      'hidden': False,
+                                                      'title': u'Type'},
+                                           'index': 7,
+                                           'value': u'task'},
+                                          {'header': {'asc': False,
+                                                      'col': u'priority',
+                                                      'hidden': False,
+                                                      'title': u'Priority'},
+                                           'index': 8,
+                                           'value': u'major'},
+                                          {'header': {'asc': False,
+                                                      'col': u'created',
+                                                      'hidden': False,
+                                                      'title': u'Created'},
+                                           'index': 9,
+                                           'value': u'...'},
+                                          {'header': {'asc': False,
+                                                      'col': u'_changetime',
+                                                      'hidden': True,
+                                                      'title': u'Changetime'},
+                                           'index': 10,
+                                           'value': u'...'},
+                                          {'header': {'asc': False,
+                                                      'col': u'_description',
+                                                      'hidden': True,
+                                                      'title': u'Description'},
+                                           'index': 11,
+                                           'value': u'Description 2'},
+                                          {'header': {'asc': False,
+                                                      'col': u'_reporter',
+                                                      'hidden': True,
+                                                      'title': u'Reporter'},
+                                           'index': 12,
+                                           'value': u'murphy'}]],
+                         'id': u'2',
+                         'resource': <Resource u'ticket:2'>}]),
+                      (u'Owned',
+                       [{u'__color__': u'4',
+                         '__idx__': 2,
+                         'cell_groups': [[{'header': {'asc': False,
+                                                      'col': u'__color__',
+                                                      'hidden': True,
+                                                      'title': u'Color'},
+                                           'index': 0,
+                                           'value': u'4'},
+                                          {'header': {'asc': False,
+                                                      'col': u'__group__',
+                                                      'hidden': True,
+                                                      'title': u'Group'},
+                                           'index': 1,
+                                           'value': u'Owned'},
+                                          {'header': {'asc': False,
+                                                      'col': u'ticket',
+                                                      'hidden': False,
+                                                      'title': u'Ticket'},
+                                           'index': 2,
+                                           'value': u'5'},
+                                          {'header': {'asc': False,
+                                                      'col': u'summary',
+                                                      'hidden': False,
+                                                      'title': u'Summary'},
+                                           'index': 3,
+                                           'value': u'Ticket 5'},
+                                          {'header': {'asc': False,
+                                                      'col': u'component',
+                                                      'hidden': False,
+                                                      'title': u'Component'},
+                                           'index': 4,
+                                           'value': ''},
+                                          {'header': {'asc': False,
+                                                      'col': u'version',
+                                                      'hidden': False,
+                                                      'title': u'Version'},
+                                           'index': 5,
+                                           'value': u'2.0'},
+                                          {'header': {'asc': False,
+                                                      'col': u'milestone',
+                                                      'hidden': False,
+                                                      'title': u'Milestone'},
+                                           'index': 6,
+                                           'value': u'milestone3'},
+                                          {'header': {'asc': False,
+                                                      'col': u'type',
+                                                      'hidden': False,
+                                                      'title': u'Type'},
+                                           'index': 7,
+                                           'value': u'task'},
+                                          {'header': {'asc': False,
+                                                      'col': u'priority',
+                                                      'hidden': False,
+                                                      'title': u'Priority'},
+                                           'index': 8,
+                                           'value': u'minor'},
+                                          {'header': {'asc': False,
+                                                      'col': u'created',
+                                                      'hidden': False,
+                                                      'title': u'Created'},
+                                           'index': 9,
+                                           'value': u'...'},
+                                          {'header': {'asc': False,
+                                                      'col': u'_changetime',
+                                                      'hidden': True,
+                                                      'title': u'Changetime'},
+                                           'index': 10,
+                                           'value': u'...'},
+                                          {'header': {'asc': False,
+                                                      'col': u'_description',
+                                                      'hidden': True,
+                                                      'title': u'Description'},
+                                           'index': 11,
+                                           'value': u'Description 5'},
+                                          {'header': {'asc': False,
+                                                      'col': u'_reporter',
+                                                      'hidden': True,
+                                                      'title': u'Reporter'},
+                                           'index': 12,
+                                           'value': u'murphy'}]],
+                         'id': u'5',
+                         'resource': <Resource u'ticket:5'>}])],
+       'sorting_enabled': False,
+       'title': u'{7} My Tickets'}
 
       ... and check for Trac=0.13 in here ;)
 
-      >>> reported_tickets = [x for x in data \
-      ...                       if x.get('__group__') == 'Reported']
-      ...
       >>> if trac_version < trac_tags[0]:
-      ...   __tester__.assertEquals(reported_tickets, [])
+      ...   __tester__.assertEquals(reported_tickets, None)
       ... else:
       ...   __tester__.assertEquals(
-      ...       [x['ticket'] for x in reported_tickets],
+      ...       [x['ticket'] for x in reported_tickets[1]],
       ...       [3, 6]
       ...     )
       ...
@@ -339,34 +684,319 @@ __test__ = {
       ...   }))
       ...
       ('widget_grid.html',
-       {'data': [{u'__color__': u'3',
-         u'__group__': u'Accepted',
-         u'_changetime': ...,
-         u'_description': u'Description 1',
-         u'_reporter': u'murphy',
-         u'component': u'component1',
-         u'created': ...,
-         u'milestone': u'milestone1',
-         u'priority': u'major',
-         u'summary': u'Ticket 1',
-         u'ticket': 1,
-         u'type': u'defect',
-         u'version': u'1.0'},
-        {u'__color__': u'3',
-         u'__group__': u'Accepted',
-         u'_changetime': ...,
-         u'_description': u'Description 2',
-         u'_reporter': u'murphy',
-         u'component': None,
-         u'created': ...,
-         u'milestone': u'milestone4',
-         u'priority': u'major',
-         u'summary': u'Ticket 2',
-         u'ticket': 2,
-         u'type': u'task',
-         u'version': None}],
-        'title': <Element "a">},
-       <...Context >)
+       {'data': {'action': 'view',
+                 'args': {'USER': 'murphy'},
+                 'context': <...Context <Resource u'report:7'>>,
+                 'description': u'\nThis report demonstrates the use of the automatically set \nUSER dynamic variable, replaced with the username of the\nlogged in user when executed.\n',
+                 'email_map': {},
+                 'header_groups': [[{'asc': False,
+                                     'col': u'__color__',
+                                     'hidden': True,
+                                     'title': u'Color'},
+                                    {'asc': False,
+                                     'col': u'__group__',
+                                     'hidden': True,
+                                     'title': u'Group'},
+                                    {'asc': False,
+                                     'col': u'ticket',
+                                     'hidden': False,
+                                     'title': u'Ticket'},
+                                    {'asc': False,
+                                     'col': u'summary',
+                                     'hidden': False,
+                                     'title': u'Summary'},
+                                    {'asc': False,
+                                     'col': u'component',
+                                     'hidden': False,
+                                     'title': u'Component'},
+                                    {'asc': False,
+                                     'col': u'version',
+                                     'hidden': False,
+                                     'title': u'Version'},
+                                    {'asc': False,
+                                     'col': u'milestone',
+                                     'hidden': False,
+                                     'title': u'Milestone'},
+                                    {'asc': False,
+                                     'col': u'type',
+                                     'hidden': False,
+                                     'title': u'Type'},
+                                    {'asc': False,
+                                     'col': u'priority',
+                                     'hidden': False,
+                                     'title': u'Priority'},
+                                    {'asc': False,
+                                     'col': u'created',
+                                     'hidden': False,
+                                     'title': u'Created'},
+                                    {'asc': False,
+                                     'col': u'_changetime',
+                                     'hidden': True,
+                                     'title': u'Changetime'},
+                                    {'asc': False,
+                                     'col': u'_description',
+                                     'hidden': True,
+                                     'title': u'Description'},
+                                    {'asc': False,
+                                     'col': u'_reporter',
+                                     'hidden': True,
+                                     'title': u'Reporter'}]],
+                 'message': None,
+                 'numrows': 3,
+                 'paginator': <trac.util.presentation.Paginator object at ...>,
+                 'report': {'id': 7, 'resource': <Resource u'report:7'>},
+                 'row_groups': [(u'Accepted',
+                                 [{u'__color__': u'3',
+                                    '__idx__': 0,
+                                    'cell_groups': [[{'header': {'asc': False,
+                                                                'col': u'__color__',
+                                                                'hidden': True,
+                                                                'title': u'Color'},
+                                                     'index': 0,
+                                                     'value': u'3'},
+                                                    {'header': {'asc': False,
+                                                                'col': u'__group__',
+                                                                'hidden': True,
+                                                                'title': u'Group'},
+                                                     'index': 1,
+                                                     'value': u'Accepted'},
+                                                    {'header': {'asc': False,
+                                                                'col': u'ticket',
+                                                                'hidden': False,
+                                                                'title': u'Ticket'},
+                                                     'index': 2,
+                                                     'value': u'1'},
+                                                    {'header': {'asc': False,
+                                                                'col': u'summary',
+                                                                'hidden': False,
+                                                                'title': u'Summary'},
+                                                     'index': 3,
+                                                     'value': u'Ticket 1'},
+                                                    {'header': {'asc': False,
+                                                                'col': u'component',
+                                                                'hidden': False,
+                                                                'title': u'Component'},
+                                                     'index': 4,
+                                                     'value': u'component1'},
+                                                    {'header': {'asc': False,
+                                                                'col': u'version',
+                                                                'hidden': False,
+                                                                'title': u'Version'},
+                                                     'index': 5,
+                                                     'value': u'1.0'},
+                                                    {'header': {'asc': False,
+                                                                'col': u'milestone',
+                                                                'hidden': False,
+                                                                'title': u'Milestone'},
+                                                     'index': 6,
+                                                     'value': u'milestone1'},
+                                                    {'header': {'asc': False,
+                                                                'col': u'type',
+                                                                'hidden': False,
+                                                                'title': u'Type'},
+                                                     'index': 7,
+                                                     'value': u'defect'},
+                                                    {'header': {'asc': False,
+                                                                'col': u'priority',
+                                                                'hidden': False,
+                                                                'title': u'Priority'},
+                                                     'index': 8,
+                                                     'value': u'major'},
+                                                    {'header': {'asc': False,
+                                                                'col': u'created',
+                                                                'hidden': False,
+                                                                'title': u'Created'},
+                                                     'index': 9,
+                                                     'value': u'...'},
+                                                    {'header': {'asc': False,
+                                                                'col': u'_changetime',
+                                                                'hidden': True,
+                                                                'title': u'Changetime'},
+                                                     'index': 10,
+                                                     'value': u'...'},
+                                                    {'header': {'asc': False,
+                                                                'col': u'_description',
+                                                                'hidden': True,
+                                                                'title': u'Description'},
+                                                     'index': 11,
+                                                     'value': u'Description 1'},
+                                                    {'header': {'asc': False,
+                                                                'col': u'_reporter',
+                                                                'hidden': True,
+                                                                'title': u'Reporter'},
+                                                     'index': 12,
+                                                     'value': u'murphy'}]],
+                                    'id': u'1',
+                                    'resource': <Resource u'ticket:1'>},
+                                  {u'__color__': u'3',
+                                    '__idx__': 1,
+                                    'cell_groups': [[{'header': {'asc': False,
+                                                                'col': u'__color__',
+                                                                'hidden': True,
+                                                                'title': u'Color'},
+                                                     'index': 0,
+                                                     'value': u'3'},
+                                                    {'header': {'asc': False,
+                                                                'col': u'__group__',
+                                                                'hidden': True,
+                                                                'title': u'Group'},
+                                                     'index': 1,
+                                                     'value': u'Accepted'},
+                                                    {'header': {'asc': False,
+                                                                'col': u'ticket',
+                                                                'hidden': False,
+                                                                'title': u'Ticket'},
+                                                     'index': 2,
+                                                     'value': u'2'},
+                                                    {'header': {'asc': False,
+                                                                'col': u'summary',
+                                                                'hidden': False,
+                                                                'title': u'Summary'},
+                                                     'index': 3,
+                                                     'value': u'Ticket 2'},
+                                                    {'header': {'asc': False,
+                                                                'col': u'component',
+                                                                'hidden': False,
+                                                                'title': u'Component'},
+                                                     'index': 4,
+                                                     'value': ''},
+                                                    {'header': {'asc': False,
+                                                                'col': u'version',
+                                                                'hidden': False,
+                                                                'title': u'Version'},
+                                                     'index': 5,
+                                                     'value': ''},
+                                                    {'header': {'asc': False,
+                                                                'col': u'milestone',
+                                                                'hidden': False,
+                                                                'title': u'Milestone'},
+                                                     'index': 6,
+                                                     'value': u'milestone4'},
+                                                    {'header': {'asc': False,
+                                                                'col': u'type',
+                                                                'hidden': False,
+                                                                'title': u'Type'},
+                                                     'index': 7,
+                                                     'value': u'task'},
+                                                    {'header': {'asc': False,
+                                                                'col': u'priority',
+                                                                'hidden': False,
+                                                                'title': u'Priority'},
+                                                     'index': 8,
+                                                     'value': u'major'},
+                                                    {'header': {'asc': False,
+                                                                'col': u'created',
+                                                                'hidden': False,
+                                                                'title': u'Created'},
+                                                     'index': 9,
+                                                     'value': u'...'},
+                                                    {'header': {'asc': False,
+                                                                'col': u'_changetime',
+                                                                'hidden': True,
+                                                                'title': u'Changetime'},
+                                                     'index': 10,
+                                                     'value': u'...'},
+                                                    {'header': {'asc': False,
+                                                                'col': u'_description',
+                                                                'hidden': True,
+                                                                'title': u'Description'},
+                                                     'index': 11,
+                                                     'value': u'Description 2'},
+                                                    {'header': {'asc': False,
+                                                                'col': u'_reporter',
+                                                                'hidden': True,
+                                                                'title': u'Reporter'},
+                                                     'index': 12,
+                                                     'value': u'murphy'}]],
+                                    'id': u'2',
+                                    'resource': <Resource u'ticket:2'>}]),
+                                (u'Owned',
+                                 [{u'__color__': u'4',
+                                    '__idx__': 2,
+                                    'cell_groups': [[{'header': {'asc': False,
+                                                                'col': u'__color__',
+                                                                'hidden': True,
+                                                                'title': u'Color'},
+                                                     'index': 0,
+                                                     'value': u'4'},
+                                                    {'header': {'asc': False,
+                                                                'col': u'__group__',
+                                                                'hidden': True,
+                                                                'title': u'Group'},
+                                                     'index': 1,
+                                                     'value': u'Owned'},
+                                                    {'header': {'asc': False,
+                                                                'col': u'ticket',
+                                                                'hidden': False,
+                                                                'title': u'Ticket'},
+                                                     'index': 2,
+                                                     'value': u'5'},
+                                                    {'header': {'asc': False,
+                                                                'col': u'summary',
+                                                                'hidden': False,
+                                                                'title': u'Summary'},
+                                                     'index': 3,
+                                                     'value': u'Ticket 5'},
+                                                    {'header': {'asc': False,
+                                                                'col': u'component',
+                                                                'hidden': False,
+                                                                'title': u'Component'},
+                                                     'index': 4,
+                                                     'value': ''},
+                                                    {'header': {'asc': False,
+                                                                'col': u'version',
+                                                                'hidden': False,
+                                                                'title': u'Version'},
+                                                     'index': 5,
+                                                     'value': u'2.0'},
+                                                    {'header': {'asc': False,
+                                                                'col': u'milestone',
+                                                                'hidden': False,
+                                                                'title': u'Milestone'},
+                                                     'index': 6,
+                                                     'value': u'milestone3'},
+                                                    {'header': {'asc': False,
+                                                                'col': u'type',
+                                                                'hidden': False,
+                                                                'title': u'Type'},
+                                                     'index': 7,
+                                                     'value': u'task'},
+                                                    {'header': {'asc': False,
+                                                                'col': u'priority',
+                                                                'hidden': False,
+                                                                'title': u'Priority'},
+                                                     'index': 8,
+                                                     'value': u'minor'},
+                                                    {'header': {'asc': False,
+                                                                'col': u'created',
+                                                                'hidden': False,
+                                                                'title': u'Created'},
+                                                     'index': 9,
+                                                     'value': u'...'},
+                                                    {'header': {'asc': False,
+                                                                'col': u'_changetime',
+                                                                'hidden': True,
+                                                                'title': u'Changetime'},
+                                                     'index': 10,
+                                                     'value': u'...'},
+                                                    {'header': {'asc': False,
+                                                                'col': u'_description',
+                                                                'hidden': True,
+                                                                'title': u'Description'},
+                                                     'index': 11,
+                                                     'value': u'Description 5'},
+                                                    {'header': {'asc': False,
+                                                                'col': u'_reporter',
+                                                                'hidden': True,
+                                                                'title': u'Reporter'},
+                                                     'index': 12,
+                                                     'value': u'murphy'}]],
+                                    'id': u'5',
+                                    'resource': <Resource u'ticket:5'>}])],
+                 'sorting_enabled': False,
+                 'title': u'{7} My Tickets'},
+       'title': <Element "a">},
+       <...Context <Resource u'report:7'>>)
       """,
     '|TicketReport: Invalid widget name' : r"""
       >>> widget.render_widget('OlkswSk', ctx, {
@@ -384,7 +1014,7 @@ __test__ = {
       ...
       Traceback (most recent call last):
         ...
-      InvalidIdentifier: Report 99999 does not exist
+      InvalidIdentifier: Report 99999 does not exist.
       """,
     '|TicketReport: Missing required arguments' : r"""
       >>> widget.render_widget('TicketReport', ctx, {
@@ -457,21 +1087,319 @@ __test__ = {
       ...   }))
       ...
       ('widget_grid.html',
-       {'data': [{u'__color__': u'3',
-         u'__group__': u'Accepted',
-         u'_changetime': ...,
-         u'_description': u'Description 1',
-         u'_reporter': u'murphy',
-         u'component': u'component1',
-         u'created': ...,
-         u'milestone': u'milestone1',
-         u'priority': u'major',
-         u'summary': u'Ticket 1',
-         u'ticket': 1,
-         u'type': u'defect',
-         u'version': u'1.0'}],
+       {'data': {'action': 'view',
+                 'args': {'USER': 'murphy'},
+                 'context': <...Context <Resource u'report:7'>>,
+                 'description': u'\nThis report demonstrates the use of the automatically set \nUSER dynamic variable, replaced with the username of the\nlogged in user when executed.\n',
+                 'email_map': {},
+                 'header_groups': [[{'asc': False,
+                                     'col': u'__color__',
+                                     'hidden': True,
+                                     'title': u'Color'},
+                                    {'asc': False,
+                                     'col': u'__group__',
+                                     'hidden': True,
+                                     'title': u'Group'},
+                                    {'asc': False,
+                                     'col': u'ticket',
+                                     'hidden': False,
+                                     'title': u'Ticket'},
+                                    {'asc': False,
+                                     'col': u'summary',
+                                     'hidden': False,
+                                     'title': u'Summary'},
+                                    {'asc': False,
+                                     'col': u'component',
+                                     'hidden': False,
+                                     'title': u'Component'},
+                                    {'asc': False,
+                                     'col': u'version',
+                                     'hidden': False,
+                                     'title': u'Version'},
+                                    {'asc': False,
+                                     'col': u'milestone',
+                                     'hidden': False,
+                                     'title': u'Milestone'},
+                                    {'asc': False,
+                                     'col': u'type',
+                                     'hidden': False,
+                                     'title': u'Type'},
+                                    {'asc': False,
+                                     'col': u'priority',
+                                     'hidden': False,
+                                     'title': u'Priority'},
+                                    {'asc': False,
+                                     'col': u'created',
+                                     'hidden': False,
+                                     'title': u'Created'},
+                                    {'asc': False,
+                                     'col': u'_changetime',
+                                     'hidden': True,
+                                     'title': u'Changetime'},
+                                    {'asc': False,
+                                     'col': u'_description',
+                                     'hidden': True,
+                                     'title': u'Description'},
+                                    {'asc': False,
+                                     'col': u'_reporter',
+                                     'hidden': True,
+                                     'title': u'Reporter'}]],
+                 'message': None,
+                 'numrows': 3,
+                 'paginator': <trac.util.presentation.Paginator object at ...>,
+                 'report': {'id': 7, 'resource': <Resource u'report:7'>},
+                 'row_groups': [(u'Accepted',
+                                 [{u'__color__': u'3',
+                                   '__idx__': 0,
+                                   'cell_groups': [[{'header': {'asc': False,
+                                                                'col': u'__color__',
+                                                                'hidden': True,
+                                                                'title': u'Color'},
+                                                     'index': 0,
+                                                     'value': u'3'},
+                                                    {'header': {'asc': False,
+                                                                'col': u'__group__',
+                                                                'hidden': True,
+                                                                'title': u'Group'},
+                                                     'index': 1,
+                                                     'value': u'Accepted'},
+                                                    {'header': {'asc': False,
+                                                                'col': u'ticket',
+                                                                'hidden': False,
+                                                                'title': u'Ticket'},
+                                                     'index': 2,
+                                                     'value': u'1'},
+                                                    {'header': {'asc': False,
+                                                                'col': u'summary',
+                                                                'hidden': False,
+                                                                'title': u'Summary'},
+                                                     'index': 3,
+                                                     'value': u'Ticket 1'},
+                                                    {'header': {'asc': False,
+                                                                'col': u'component',
+                                                                'hidden': False,
+                                                                'title': u'Component'},
+                                                     'index': 4,
+                                                     'value': u'component1'},
+                                                    {'header': {'asc': False,
+                                                                'col': u'version',
+                                                                'hidden': False,
+                                                                'title': u'Version'},
+                                                     'index': 5,
+                                                     'value': u'1.0'},
+                                                    {'header': {'asc': False,
+                                                                'col': u'milestone',
+                                                                'hidden': False,
+                                                                'title': u'Milestone'},
+                                                     'index': 6,
+                                                     'value': u'milestone1'},
+                                                    {'header': {'asc': False,
+                                                                'col': u'type',
+                                                                'hidden': False,
+                                                                'title': u'Type'},
+                                                     'index': 7,
+                                                     'value': u'defect'},
+                                                    {'header': {'asc': False,
+                                                                'col': u'priority',
+                                                                'hidden': False,
+                                                                'title': u'Priority'},
+                                                     'index': 8,
+                                                     'value': u'major'},
+                                                    {'header': {'asc': False,
+                                                                'col': u'created',
+                                                                'hidden': False,
+                                                                'title': u'Created'},
+                                                     'index': 9,
+                                                     'value': u'...'},
+                                                    {'header': {'asc': False,
+                                                                'col': u'_changetime',
+                                                                'hidden': True,
+                                                                'title': u'Changetime'},
+                                                     'index': 10,
+                                                     'value': u'...'},
+                                                    {'header': {'asc': False,
+                                                                'col': u'_description',
+                                                                'hidden': True,
+                                                                'title': u'Description'},
+                                                     'index': 11,
+                                                     'value': u'Description 1'},
+                                                    {'header': {'asc': False,
+                                                                'col': u'_reporter',
+                                                                'hidden': True,
+                                                                'title': u'Reporter'},
+                                                     'index': 12,
+                                                     'value': u'murphy'}]],
+                                   'id': u'1',
+                                   'resource': <Resource u'ticket:1'>},
+                                  {u'__color__': u'3',
+                                   '__idx__': 1,
+                                   'cell_groups': [[{'header': {'asc': False,
+                                                                'col': u'__color__',
+                                                                'hidden': True,
+                                                                'title': u'Color'},
+                                                     'index': 0,
+                                                     'value': u'3'},
+                                                    {'header': {'asc': False,
+                                                                'col': u'__group__',
+                                                                'hidden': True,
+                                                                'title': u'Group'},
+                                                     'index': 1,
+                                                     'value': u'Accepted'},
+                                                    {'header': {'asc': False,
+                                                                'col': u'ticket',
+                                                                'hidden': False,
+                                                                'title': u'Ticket'},
+                                                     'index': 2,
+                                                     'value': u'2'},
+                                                    {'header': {'asc': False,
+                                                                'col': u'summary',
+                                                                'hidden': False,
+                                                                'title': u'Summary'},
+                                                     'index': 3,
+                                                     'value': u'Ticket 2'},
+                                                    {'header': {'asc': False,
+                                                                'col': u'component',
+                                                                'hidden': False,
+                                                                'title': u'Component'},
+                                                     'index': 4,
+                                                     'value': ''},
+                                                    {'header': {'asc': False,
+                                                                'col': u'version',
+                                                                'hidden': False,
+                                                                'title': u'Version'},
+                                                     'index': 5,
+                                                     'value': ''},
+                                                    {'header': {'asc': False,
+                                                                'col': u'milestone',
+                                                                'hidden': False,
+                                                                'title': u'Milestone'},
+                                                     'index': 6,
+                                                     'value': u'milestone4'},
+                                                    {'header': {'asc': False,
+                                                                'col': u'type',
+                                                                'hidden': False,
+                                                                'title': u'Type'},
+                                                     'index': 7,
+                                                     'value': u'task'},
+                                                    {'header': {'asc': False,
+                                                                'col': u'priority',
+                                                                'hidden': False,
+                                                                'title': u'Priority'},
+                                                     'index': 8,
+                                                     'value': u'major'},
+                                                    {'header': {'asc': False,
+                                                                'col': u'created',
+                                                                'hidden': False,
+                                                                'title': u'Created'},
+                                                     'index': 9,
+                                                     'value': u'...'},
+                                                    {'header': {'asc': False,
+                                                                'col': u'_changetime',
+                                                                'hidden': True,
+                                                                'title': u'Changetime'},
+                                                     'index': 10,
+                                                     'value': u'...'},
+                                                    {'header': {'asc': False,
+                                                                'col': u'_description',
+                                                                'hidden': True,
+                                                                'title': u'Description'},
+                                                     'index': 11,
+                                                     'value': u'Description 2'},
+                                                    {'header': {'asc': False,
+                                                                'col': u'_reporter',
+                                                                'hidden': True,
+                                                                'title': u'Reporter'},
+                                                     'index': 12,
+                                                     'value': u'murphy'}]],
+                                   'id': u'2',
+                                   'resource': <Resource u'ticket:2'>}]),
+                                (u'Owned',
+                                 [{u'__color__': u'4',
+                                   '__idx__': 2,
+                                   'cell_groups': [[{'header': {'asc': False,
+                                                                'col': u'__color__',
+                                                                'hidden': True,
+                                                                'title': u'Color'},
+                                                     'index': 0,
+                                                     'value': u'4'},
+                                                    {'header': {'asc': False,
+                                                                'col': u'__group__',
+                                                                'hidden': True,
+                                                                'title': u'Group'},
+                                                     'index': 1,
+                                                     'value': u'Owned'},
+                                                    {'header': {'asc': False,
+                                                                'col': u'ticket',
+                                                                'hidden': False,
+                                                                'title': u'Ticket'},
+                                                     'index': 2,
+                                                     'value': u'5'},
+                                                    {'header': {'asc': False,
+                                                                'col': u'summary',
+                                                                'hidden': False,
+                                                                'title': u'Summary'},
+                                                     'index': 3,
+                                                     'value': u'Ticket 5'},
+                                                    {'header': {'asc': False,
+                                                                'col': u'component',
+                                                                'hidden': False,
+                                                                'title': u'Component'},
+                                                     'index': 4,
+                                                     'value': ''},
+                                                    {'header': {'asc': False,
+                                                                'col': u'version',
+                                                                'hidden': False,
+                                                                'title': u'Version'},
+                                                     'index': 5,
+                                                     'value': u'2.0'},
+                                                    {'header': {'asc': False,
+                                                                'col': u'milestone',
+                                                                'hidden': False,
+                                                                'title': u'Milestone'},
+                                                     'index': 6,
+                                                     'value': u'milestone3'},
+                                                    {'header': {'asc': False,
+                                                                'col': u'type',
+                                                                'hidden': False,
+                                                                'title': u'Type'},
+                                                     'index': 7,
+                                                     'value': u'task'},
+                                                    {'header': {'asc': False,
+                                                                'col': u'priority',
+                                                                'hidden': False,
+                                                                'title': u'Priority'},
+                                                     'index': 8,
+                                                     'value': u'minor'},
+                                                    {'header': {'asc': False,
+                                                                'col': u'created',
+                                                                'hidden': False,
+                                                                'title': u'Created'},
+                                                     'index': 9,
+                                                     'value': u'...'},
+                                                    {'header': {'asc': False,
+                                                                'col': u'_changetime',
+                                                                'hidden': True,
+                                                                'title': u'Changetime'},
+                                                     'index': 10,
+                                                     'value': u'...'},
+                                                    {'header': {'asc': False,
+                                                                'col': u'_description',
+                                                                'hidden': True,
+                                                                'title': u'Description'},
+                                                     'index': 11,
+                                                     'value': u'Description 5'},
+                                                    {'header': {'asc': False,
+                                                                'col': u'_reporter',
+                                                                'hidden': True,
+                                                                'title': u'Reporter'},
+                                                     'index': 12,
+                                                     'value': u'murphy'}]],
+                                   'id': u'5',
+                                   'resource': <Resource u'ticket:5'>}])],
+                 'sorting_enabled': False,
+                 'title': u'{7} My Tickets'},
         'title': <Element "a">},
-       <...Context >)
+       <...Context <Resource u'report:7'>>)
       """,
     '|TicketReport: Invalid report definition' : r"""
       >>> raise NotImplementedError()

Modified: incubator/bloodhound/trunk/bloodhound_dashboard/bhdashboard/util.py
URL: http://svn.apache.org/viewvc/incubator/bloodhound/trunk/bloodhound_dashboard/bhdashboard/util.py?rev=1307967&r1=1307966&r2=1307967&view=diff
==============================================================================
--- incubator/bloodhound/trunk/bloodhound_dashboard/bhdashboard/util.py (original)
+++ incubator/bloodhound/trunk/bloodhound_dashboard/bhdashboard/util.py Sun Apr  1 00:54:22 2012
@@ -26,6 +26,7 @@ Helper functions and classes.
 
 from functools import update_wrapper
 import inspect
+from pkg_resources import get_distribution
 from urlparse import urlparse
 
 from trac.core import Component, implements
@@ -116,3 +117,17 @@ def pretty_wrapper(wrapped, *decorators)
         wrapper = f(wrapper)
     return update_wrapper(wrapper, wrapped)
 
+#------------------------------------------------------
+#    Context information
+#------------------------------------------------------
+
+trac_version = tuple(int(i) for i in get_distribution('Trac').parsed_version \
+                            if i.startswith('0'))
+
+# The exact moments (versions) where some things started to change
+# in such a manner that break previous test code
+
+trac_tags = (
+        (0, 13), # TODO: Find the exact version ( Trac=0.12 ? )
+    )
+

Modified: incubator/bloodhound/trunk/bloodhound_dashboard/bhdashboard/web_ui.py
URL: http://svn.apache.org/viewvc/incubator/bloodhound/trunk/bloodhound_dashboard/bhdashboard/web_ui.py?rev=1307967&r1=1307966&r2=1307967&view=diff
==============================================================================
--- incubator/bloodhound/trunk/bloodhound_dashboard/bhdashboard/web_ui.py (original)
+++ incubator/bloodhound/trunk/bloodhound_dashboard/bhdashboard/web_ui.py Sun Apr  1 00:54:22 2012
@@ -51,7 +51,6 @@ class DashboardModule(Component):
         """Initially this will render static widgets. With time it will be 
         more and more dynamic and flexible.
         """
-        #add_stylesheet(req, 'dashboard/reset-fonts-grids.css')
         add_stylesheet(req, 'dashboard/grids.css')
         add_stylesheet(req, 'dashboard/skin.css')
         return 'bhdb_one_col.html', \

Modified: incubator/bloodhound/trunk/bloodhound_dashboard/bhdashboard/widgets/report.py
URL: http://svn.apache.org/viewvc/incubator/bloodhound/trunk/bloodhound_dashboard/bhdashboard/widgets/report.py?rev=1307967&r1=1307966&r2=1307967&view=diff
==============================================================================
--- incubator/bloodhound/trunk/bloodhound_dashboard/bhdashboard/widgets/report.py (original)
+++ incubator/bloodhound/trunk/bloodhound_dashboard/bhdashboard/widgets/report.py Sun Apr  1 00:54:22 2012
@@ -29,11 +29,14 @@ from itertools import imap, islice
 
 from genshi.builder import tag
 from trac.core import implements, TracError
+from trac.resource import ResourceNotFound
 from trac.ticket.report import ReportModule
 from trac.util.translation import _
+from trac.web.api import RequestDone
 
 from bhdashboard.util import WidgetBase, InvalidIdentifier, \
-                              check_widget_name, pretty_wrapper
+                              check_widget_name, dummy_request, \
+                              pretty_wrapper, trac_version, trac_tags
 
 class TicketReportWidget(WidgetBase):
     """Display tickets in saved report using a grid
@@ -48,137 +51,55 @@ class TicketReportWidget(WidgetBase):
                         'required' : True,
                         'type' : int,
                     },
-                'limit' : {
-                        'default' : 0,
-                        'desc' : """Number of results to retrieve""",
+                'page' : {
+                        'default' : 1,
+                        'desc' : """Retrieve results in given page.""",
                         'type' : int,
                 },
+                'user' : {
+                        'desc' : """Render the report for a given user.""",
+                },
             }
     get_widget_params = pretty_wrapper(get_widget_params, check_widget_name)
 
     def render_widget(self, name, context, options):
         """Execute stored report and render data using a grid
         """
-        metadata = data = None
+        data = None
         req = context.req
         try:
-            rptid, limit = self.bind_params(name, options, 'id', 'limit')
-            metadata = self.get(req, rptid)
-            # TODO: Should metadata also contain columns definition ?
-            data = list(self.execute(req, rptid, limit))
-        except TracError, exc:
-            if metadata is not None :
-                exc.title = metadata.get('title', 'TracReports')
+            params = ('id', 'page', 'user')
+            rptid, page, user = self.bind_params(name, options, *params)
+            user = user or req.authname
+
+            rptreq = dummy_request(self.env, req.authname)
+            rptreq.args = {'page' : page, 'user' : user}
+            del rptreq.redirect     # raise RequestDone as usual
+
+            rptmdl = self.env[ReportModule]
+            if rptmdl is None :
+                raise TracError('Report module not available (disabled?)')
+            if trac_version < trac_tags[0]:
+                args = rptreq, self.env.get_db_cnx(), rptid
             else:
-                exc.title = 'TracReports'
+                args = rptreq, rptid
+            data = rptmdl._render_view(*args)[1]
+        except ResourceNotFound, exc:
+            raise InvalidIdentifier(unicode(exc))
+        except RequestDone:
+            raise TracError('Cannot execute report. Redirection needed')
+        except TracError, exc:
+            if data is not None:
+                exc.title = data.get('title', 'TracReports')
             raise
         else:
-            title = metadata.get('title', '%s #%s' % (_('Report'), rptid))
+            title = data.get('title', '%s {%s}' % (_('Report'), rptid))
             return 'widget_grid.html', \
                     {
                         'title' : tag.a(title, href=req.href('report', rptid)),
                         'data' : data
                     }, \
-                    context
+                    context('report', rptid)
 
     render_widget = pretty_wrapper(render_widget, check_widget_name)
 
-    # Internal methods
-
-    # These have been imported verbatim from existing 
-    # `tracgviz.rpc.ReportRPC` class in TracGViz plugin ;)
-    def get(self, req, id):
-        r"""Return information about an specific report as a dict 
-        containing the following fields.
-        
-        - id :            the report ID.
-        - title:          the report title.
-        - description:    the report description.
-        - query:          the query string used to select the tickets 
-                          to be included in this report. This field 
-                          is returned only if `REPORT_SQL_VIEW` has 
-                          been granted to the client performing the 
-                          request. Otherwise it is empty.
-        """
-        sql = "SELECT id,title,query,description from report " \
-                "WHERE id=%s" % (id,)
-        db = self.env.get_db_cnx()
-        cursor = db.cursor()
-        try:
-            cursor.execute(sql)
-            for report_info in cursor:
-                return dict(zip(['id','title','query','description'], report_info))
-            else:
-                return None
-        finally:
-            cursor.close()
-
-    def _execute_sql(self, req, id, sql, limit=0):
-        r"""Execute a SQL report and return no more than `limit` rows 
-        (or all rows if limit == 0).
-        """
-        repmdl = ReportModule(self.env)
-        db = self.env.get_db_cnx()
-        try:
-            args = repmdl.get_var_args(req)
-        except ValueError,e:
-            raise ValueError(_('Report failed: %(error)s', error=e))
-        try:
-            try:
-                # Paginated exec (>=0.11)
-                exec_proc = repmdl.execute_paginated_report
-                kwargs = dict(limit=limit)
-            except AttributeError:
-                # Legacy exec (<=0.10)
-                if limit > 0:
-                    exec_proc = lambda *args, **kwargs: \
-                        islice(repmdl.execute_report(*args, **kwargs), limit)
-                else:
-                    exec_proc = repmdl.execute_report
-                kwargs = {}
-            return exec_proc(req, db, id, sql, args, **kwargs)[:2]
-        except Exception, e:
-            db.rollback()
-            raise 
-
-    def execute(self, req, id, limit=0):
-        r"""Execute a Trac report.
-
-        @param id     the report ID.
-        @return       a list containing the data provided by the 
-                      target report.
-        @throws       `NotImplementedError` if the report definition 
-                      consists of saved custom query specified 
-                      using a URL.
-        @throws       `QuerySyntaxError` if the report definition 
-                      consists of a `TracQuery` containing syntax errors.
-        @throws       `Exception` in case of detecting any other error.
-        """
-        report_spec = self.get(req, id)
-        if report_spec is None:
-            raise InvalidIdentifier('Report %s does not exist' % (id,))
-        sql = report_spec['query']
-        query = ''.join([line.strip() for line in sql.splitlines()])
-        if query and (query[0] == '?' or query.startswith('query:?')):
-            raise NotImplementedError('Saved custom queries specified ' \
-                                  'using URLs are not supported.')
-        elif query.startswith('query:'):
-            query = Query.from_string(self.env, query[6:], report=id)
-            server_url = urlparse(req.base_url)
-            server_href = Href(urlunparse((server_url.scheme, \
-                                        server_url.netloc, \
-                                        '', '', '', '')))
-            def rel2abs(row):
-                """Turn relative value in 'href' into absolute URLs."""
-                self.log.debug('IG: Query Row %s', row)
-                url = row['href']
-                urlobj = urlparse(url)
-                if not urlobj.netloc:
-                    row['href'] = server_href(url)
-                return row
-            
-            return imap(rel2abs, query.execute(req))
-        else:
-            cols, results = self._execute_sql(req, id, sql, limit=limit)
-            return (dict(zip(cols, list(row))) for row in results)
-



Mime
View raw message