#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 , 15 years ago
comment:2 by , 14 years ago
| Cc: | 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 , 14 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 , 14 years ago
| Milestone: | next-minor-0.12.x → 0.12.3 |
|---|---|
| Resolution: | → fixed |
| Status: | new → closed |
comment:5 by , 14 years ago
| Owner: | set to |
|---|
comment:6 by , 14 years ago
| Component: | general → report system |
|---|---|
| Severity: | critical → normal |



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_realmandparent_idspecial names for that?