Edgewall Software
Modify

Opened 11 years ago

Last modified 14 months ago

#11547 new defect

Inconsistent results from get_resource_summary

Reported by: Ryan J Ollos Owned by:
Priority: normal Milestone: next-stable-1.6.x
Component: general Version: 1.0-stable
Severity: normal Keywords:
Cc: Branch:
Release Notes:
API Changes:
Internal Changes:

Description

trac.resource.get_resource_summary is inconsistent when resource.id is None:

>>> from trac.resource import Resource, get_resource_summary
>>> from trac.env import Environment
>>> env = Environment('/home/user/Workspace/tracdev/tracdev')
>>> r1 = Resource('wiki', 'WikiStart')
>>> print get_resource_summary(env, r1)
WikiStart
>>> r2 = Resource('wiki')
>>> print get_resource_summary(env, r2)
None
>>> r3 = Resource('ticket', 1)
>>> print get_resource_summary(env, r3)
u'defect: Ticket One (new)'
>>> r4 = Resource('ticket')
>>> print get_resource_summary(env, r4)
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "trac/resource.py", line 347, in get_resource_summary
    return get_resource_description(env, resource, 'summary')
  File "trac/resource.py", line 333, in get_resource_description
    return manager.get_resource_description(resource, format, **kwargs)
  File "trac/ticket/api.py", line 548, in get_resource_description
    return self.format_summary(*args)
  File "trac/ticket/api.py", line 554, in format_summary
    summary = type + ': ' + summary
TypeError: coercing to Unicode: need string or buffer, NoneType found
>>> r5 = Resource('milestone', 'milestone1')
>>> print get_resource_summary(env, r5)
Milestone milestone1
>>> r6 = Resource('milestone')
>>> print get_resource_summary(env, r6)
Milestone None
>>> r7 = Resource('changeset', 1)
>>> print get_resource_summary(env, r7)
Changeset 1
>>> r8 = Resource('changeset')
>>> print get_resource_summary(env, r8)
Changeset None
>>> r9 = Resource('attachment', 'SearchResults.png', parent=Resource('ticket', 1))
>>> print get_resource_summary(env, r9)

>>> r10 = Resource('attachment', parent=Resource('ticket', 1))
>>> print get_resource_summary(env, r10)
None

We should fix the case of Resource('ticket') so that it returns None rather than raising an exception.

Attachments (0)

Change History (6)

comment:1 by Ryan J Ollos, 11 years ago

Milestone: next-stable-1.0.x1.0.3

comment:2 by Ryan J Ollos, 10 years ago

Status: newassigned

comment:3 by Ryan J Ollos, 10 years ago

Milestone: 1.0.3next-stable-1.0.x
Owner: Ryan J Ollos removed
Status: assignednew

comment:4 by Ryan J Ollos, 8 years ago

Milestone: next-stable-1.0.xnext-stable-1.2.x

Moved ticket assigned to next-stable-1.0.x since maintenance of 1.0.x is coming to a close. Please move the ticket back if it's critical to fix on 1.0.x.

comment:5 by Ryan J Ollos, 5 years ago

Milestone: next-stable-1.2.xnext-stable-1.4.x

comment:6 by Ryan J Ollos, 14 months ago

Milestone: next-stable-1.4.xnext-stable-1.6.x

Milestone renamed

Modify Ticket

Change Properties
Set your email in Preferences
Action
as new The ticket will remain with no owner.
The ticket will be disowned.
as The resolution will be set. Next status will be 'closed'.
The owner will be changed from (none) to anonymous. Next status will be 'assigned'.

Add Comment


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