Edgewall Software
Modify

Ticket #4247 (closed defect: fixed)

Opened 5 years ago

Last modified 5 years ago

Ticket Model Component sets wrong 'exists' status

Reported by: simon-code@… Owned by: jonas
Priority: normal Milestone: 0.11
Component: ticket system Version: 0.10.2
Severity: minor Keywords:
Cc:
Release Notes:
API Changes:

Description

I am trying to remove the default created components from the Ticket system using Ticket Model (through code), but the result is a Traceback: AssertionError: Cannot deleting non-existent component (typo here by the way :-)

Somehow trac.ticket.model.Component sets the wrong exists status - illustration from a new (default) Trac environment (it only seems to affect Component):

>>> from trac.env import Environment
>>> myenv = Environment('/path/to/my/env')
>>> from trac.ticket.model import Priority, Component, Milestone
>>> for milestone in Milestone(myenv).select(myenv):
        print milestone.name, milestone.exists
milestone1 True
milestone2 True
milestone3 True
milestone4 True
>>> for priority in Priority(myenv).select(myenv):
        print priority.name, priority.exists
blocker True
critical True
major True
minor True
trivial True
>>> for component in Component(myenv).select(myenv):
        print component.name, component.exists
component1 False
component2 False

Attachments

t4247.diff (2.9 KB) - added by Tim Hatch <trac@…> 5 years ago.
Patch against trunk#4335 including unit test for this issue

Download all attachments as: .zip

Change History

comment:1 Changed 5 years ago by simon-code@…

Decided to test them all, and it also happens for Version:

>>> from trac.ticket.model import Version
>>> for version in Version(myenv).select(myenv):
        print version.name, version.exists
2.0 False
1.0 False

Other property types tested OK.

Changed 5 years ago by Tim Hatch <trac@…>

Patch against trunk#4335 including unit test for this issue

comment:2 Changed 5 years ago by Tim Hatch <trac@…>

Confirmed in trunk. Component and Version use custom classes, but most other classes under trac.ticket.model derive from AbstractEnum which was properly setting _old_name in select(). I've attached t4247.diff (and the # in the attachment description was supposed to be @)

comment:3 Changed 5 years ago by simon-code@…

That seems to solve it. Thanks for spotting and preparing a fix!

comment:4 Changed 5 years ago by cboos

  • Milestone set to 0.11
  • Resolution set to fixed
  • Severity changed from normal to minor
  • Status changed from new to closed

Thanks! Patch applied in r4350.

View

Add a comment

Modify Ticket

Change Properties
<Author field>
Action
as closed
The resolution will be deleted. Next status will be 'reopened'
to The owner will be changed from jonas. Next status will be 'closed'
Author


E-mail address and user name can be saved in the Preferences.

 
Note: See TracTickets for help on using tickets.