Edgewall Software
Modify

Opened 14 years ago

Closed 13 years ago

Last modified 13 years ago

#10061 closed defect (fixed)

realm changeset for reports not handeld properly

Reported by: anonymous Owned by: Jun Omae
Priority: normal Milestone: 0.12.3
Component: report system Version: 0.12.2
Severity: normal Keywords: bitesized
Cc: mpotter@… Branch:
Release Notes:
API Changes:
Internal Changes:

Description

Hi,

I wanted to try to use realm changeset for reports, and stumbled over:

http://trac.edgewall.org/wiki/CookBook/Configuration/Reports

and wanted to try out the following report:

SELECT 
   "changeset" AS _realm, rev as id, 
   time AS date, time, 
   SUBSTR(message, 1, 80 )AS message
FROM revision
WHERE author='$USER'
ORDER BY time DESC

which did not work in trac (fresh 0.12.2), it returned an error:

AttributeError: 'NoneType' object has no attribute 'id'

with the following backtrace:

File "/usr/lib/python2.4/site-packages/trac/ticket/templates/report_view.html", line 142, in <Expression u'url_of(row.resource)'>
  <a title="${_('View %(realm)s', realm=row.resource.realm)}"
File "/usr/lib/python2.4/site-packages/trac/web/chrome.py", line 738, in get_rel_url
  return get_resource_url(self.env, resource, href, **kwargs)
File "/usr/lib/python2.4/site-packages/trac/resource.py", line 297, in get_resource_url
  return manager.get_resource_url(resource, href, **kwargs)
File "/usr/lib/python2.4/site-packages/trac/versioncontrol/api.py", line 385, in get_resource_url
  return href.changeset(resource.id, resource.parent.id or None)

I think that this is caused by the following code in api.py:

      def get_resource_url(self, resource, href, **kwargs):
          if resource.realm == 'changeset':
              return href.changeset(resource.id, resource.parent.id or None)
          elif resource.realm == 'source':
              return href.source(resource.parent.id or None, resource.id)
          elif resource.realm == 'repository':
              return href.source(resource.id or None)

especially the "resource.id, resource.parent.id or None" part. resource.parent is not set here, and as such .id cannot be accessed. I worked around this by doing:

          if resource.realm == 'changeset':
              if resource.parent:
                  return href.changeset(resource.id, resource.parent.id or None)
              else:
                  return href.changeset(resource.id, None)

however I am not sure if resource.parent may even ever be None at this point. Nevertheless my reports work as intended (sans bug #9254 which I also would like to be solved)

Attachments (0)

Change History (6)

comment:1 by Remy Blank, 14 years ago

Unfortunately it's more complicated than that. Changeset resources are required to have a parent, which is the repository to which the changeset belongs. There's currently no way to create a resource with a parent from a report. Maybe we could add parent_realm and parent_id special names for that?

comment:2 by Mark Potter <mpotter@…>, 13 years ago

Cc: mpotter@… added

I just upgraded from 0.11.7 to 0.12.2 and a report that used this feature stopped working with this error.

comment:3 by Remy Blank, 13 years ago

Keywords: bitesized added
Milestone: next-minor-0.12.x

We should keep this on the radar. Implementing the special names parent_realm and parent_id shouldn't be difficult.

comment:4 by Jun Omae, 13 years ago

Milestone: next-minor-0.12.x0.12.3
Resolution: fixed
Status: newclosed

In [10867], adds support for parent_realm and parent_id.

Related to #9254.

comment:5 by Jun Omae, 13 years ago

Owner: set to Jun Omae

comment:6 by Jun Omae, 13 years ago

Component: generalreport system
Severity: criticalnormal

Modify Ticket

Change Properties
Set your email in Preferences
Action
as closed The owner will remain Jun Omae.
The resolution will be deleted. Next status will be 'reopened'.
to The owner will be changed from Jun Omae to the specified user.

Add Comment


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