Opened 13 years ago
Closed 12 years ago
#9714 closed defect (fixed)
JsGantt fails with ChildTickets plugin and non-numeric parent value (#%s)
Reported by: | rzhidalgo@yahoo.com | Owned by: | Chris Nelson |
---|---|---|---|
Priority: | normal | Component: | TracJsGanttPlugin |
Severity: | normal | Keywords: | |
Cc: | Trac Release: | 0.11 |
Description (last modified by )
Trac JsGantt plugin fails to generate the chart with the following log error message: ---
2012-01-20 17:44:43,257 Trac[formatter] ERROR: Macro TracJSGanttChart(milestone=Milestone1, res=0, format=quarter) failed: Traceback (most recent call last): File "build/bdist.linux-i686/egg/trac/wiki/formatter.py", line 717, in _macro_formatter return macro.process(args, in_paragraph=True) File "build/bdist.linux-i686/egg/trac/wiki/formatter.py", line 304, in process text = self.processor(text) File "build/bdist.linux-i686/egg/trac/wiki/formatter.py", line 291, in _macro_processor text) File "build/bdist.linux-i686/egg/tracjsgantt/tracjsgantt.py", line 612, in expand_macro tasks = self._add_tasks(options) File "build/bdist.linux-i686/egg/tracjsgantt/tracjsgantt.py", line 565, in _add_tasks self.tickets.sort(key=itemgetter('wbs')) KeyError: 'wbs'
--- The ChildTickets plugin requires a '#' sign before the ticket number as a parent field value, which seems to be causing the problem.
Attachments (0)
Change History (21)
comment:1 Changed 13 years ago by
Description: | modified (diff) |
---|
comment:2 Changed 13 years ago by
comment:3 Changed 13 years ago by
Status: | new → assigned |
---|
comment:4 follow-up: 5 Changed 13 years ago by
Yes, the parent_format was already set to '#%s'. We've been using JsGantt and ChildTickets for a while but the later version (r11133), with 'tracjsgantt.tracpm.*', started showing the 'wbs' error.
comment:5 Changed 13 years ago by
comment:6 Changed 13 years ago by
comment:7 follow-up: 8 Changed 13 years ago by
Please send me the lines that this change puts in trac.log so I can try to solve your problem. Thanks.
comment:8 follow-up: 9 Changed 13 years ago by
Replying to ChrisNelson:
Please send me the lines that this change puts in trac.log so I can try to solve your problem. Thanks.
Here's the log:
2012-01-23 12:28:04,575 Trac[tracjsgantt] DEBUG: Computing WBS 2012-01-23 12:28:04,576 Trac[tracjsgantt] DEBUG: Computing for 749 2012-01-23 12:28:04,576 Trac[tracjsgantt] DEBUG: parent is 0 2012-01-23 12:28:04,576 Trac[tracjsgantt] DEBUG: setting level 2012-01-23 12:28:04,576 Trac[tracjsgantt] DEBUG: Computing WBS for (749, [1], 1) 2012-01-23 12:28:04,576 Trac[tracjsgantt] DEBUG: 749 has children [] 2012-01-23 12:28:04,576 Trac[tracjsgantt] DEBUG: Computing for 742 2012-01-23 12:28:04,576 Trac[tracjsgantt] DEBUG: parent is 0 2012-01-23 12:28:04,576 Trac[tracjsgantt] DEBUG: setting level 2012-01-23 12:28:04,576 Trac[tracjsgantt] DEBUG: Computing WBS for (742, [2], 1) 2012-01-23 12:28:04,576 Trac[tracjsgantt] DEBUG: 742 has children [] 2012-01-23 12:28:04,576 Trac[tracjsgantt] DEBUG: Computing for 847 2012-01-23 12:28:04,576 Trac[tracjsgantt] DEBUG: parent is 0 2012-01-23 12:28:04,576 Trac[tracjsgantt] DEBUG: setting level 2012-01-23 12:28:04,577 Trac[tracjsgantt] DEBUG: Computing WBS for (847, [3], 1) 2012-01-23 12:28:04,577 Trac[tracjsgantt] DEBUG: 847 has children [] 2012-01-23 12:28:04,577 Trac[tracjsgantt] DEBUG: Computing for 949 2012-01-23 12:28:04,577 Trac[tracjsgantt] DEBUG: parent is 0 2012-01-23 12:28:04,577 Trac[tracjsgantt] DEBUG: setting level 2012-01-23 12:28:04,577 Trac[tracjsgantt] DEBUG: Computing WBS for (949, [4], 1) 2012-01-23 12:28:04,577 Trac[tracjsgantt] DEBUG: 949 has children [382] 2012-01-23 12:28:04,577 Trac[tracjsgantt] DEBUG: Computing WBS for (382, [4, 1], 2) 2012-01-23 12:28:04,577 Trac[tracjsgantt] DEBUG: 382 has children [] 2012-01-23 12:28:04,577 Trac[tracjsgantt] DEBUG: Computing for 948 2012-01-23 12:28:04,577 Trac[tracjsgantt] DEBUG: parent is 949 2012-01-23 12:28:04,577 Trac[tracjsgantt] DEBUG: Computing for 892 2012-01-23 12:28:04,577 Trac[tracjsgantt] DEBUG: parent is 0 2012-01-23 12:28:04,577 Trac[tracjsgantt] DEBUG: setting level 2012-01-23 12:28:04,578 Trac[tracjsgantt] DEBUG: Computing WBS for (892, [5], 1) 2012-01-23 12:28:04,578 Trac[tracjsgantt] DEBUG: 892 has children [] 2012-01-23 12:28:04,578 Trac[tracjsgantt] DEBUG: Computing for 382 2012-01-23 12:28:04,578 Trac[tracjsgantt] DEBUG: parent is 949 2012-01-23 12:28:04,578 Trac[tracjsgantt] DEBUG: Computing for -1 2012-01-23 12:28:04,578 Trac[tracjsgantt] DEBUG: parent is 0 2012-01-23 12:28:04,578 Trac[tracjsgantt] DEBUG: setting level 2012-01-23 12:28:04,578 Trac[tracjsgantt] DEBUG: Computing WBS for (-1, [6], 1) 2012-01-23 12:28:04,578 Trac[tracjsgantt] DEBUG: -1 has children None 2012-01-23 12:28:04,580 Trac[formatter] ERROR: Macro TracJSGanttChart(milestone=ATMS 3.0.0, format=quarter, lwidth=700) failed: Traceback (most recent call last): File "build/bdist.linux-i686/egg/trac/wiki/formatter.py", line 717, in _macro_formatter return macro.process(args, in_paragraph=True) File "build/bdist.linux-i686/egg/trac/wiki/formatter.py", line 304, in process text = self.processor(text) File "build/bdist.linux-i686/egg/trac/wiki/formatter.py", line 291, in _macro_processor text) File "build/bdist.linux-i686/egg/tracjsgantt/tracjsgantt.py", line 619, in expand_macro tasks = self._add_tasks(options) File "build/bdist.linux-i686/egg/tracjsgantt/tracjsgantt.py", line 572, in _add_tasks self.tickets.sort(key=itemgetter('wbs')) KeyError: 'wbs'
The tickets are 749, 742, 847, 892, and 949 (children(382,948)).
The parent field has #949.
The compute_wbs is okay, but the tickets.sort is failing.
Thanks for your help.
comment:9 Changed 13 years ago by
Replying to rozhi:
Replying to ChrisNelson:
Please send me the lines that this change puts in trac.log so I can try to solve your problem. Thanks.
Here's the log: ... The compute_wbs is okay, but the tickets.sort is failing.
Yes, but the sort is failing because the wbs field is missing and it should only be missing if computing the wbs failed or was skipped.
comment:10 follow-up: 11 Changed 13 years ago by
The pseudoticket for the milestone (ticket ID -1) had children None
.
children
should only be None
if no parent field is configured. But the parent field is configured because some tickets have no children ([]
) and 949 has child 382.
I don't see any way for []
and None
to both be used with the same configuration.
Can you post your [TracPM]
section of trac.ini
?
comment:11 follow-up: 12 Changed 13 years ago by
Replying to ChrisNelson:
The pseudoticket for the milestone (ticket ID -1) had children
None
.
children
should only beNone
if no parent field is configured. But the parent field is configured because some tickets have no children ([]
) and 949 has child 382.I don't see any way for
[]
andNone
to both be used with the same configuration.Can you post your
[TracPM]
section oftrac.ini
?
Any news?
comment:12 follow-up: 13 Changed 13 years ago by
Replying to ChrisNelson:
Replying to ChrisNelson:
The pseudoticket for the milestone (ticket ID -1) had children
None
.
children
should only beNone
if no parent field is configured. But the parent field is configured because some tickets have no children ([]
) and 949 has child 382.I don't see any way for
[]
andNone
to both be used with the same configuration.Can you post your
[TracPM]
section oftrac.ini
?Any news?
I'm trying to do some debugging also. I manually changed the Childticket parent values (removed #), and it sucessfully generate the chart. Both logs (good and failing) have [] and None. The difference is the failing code did not find all the children. Ticket 949 has children 382 and 948.
Fail (parent value with #):
2012-01-26 15:18:55,859 Trac[tracjsgantt] DEBUG: Computing WBS for (949, [4], 1) 2012-01-26 15:18:55,859 Trac[tracjsgantt] DEBUG: 949 has children [382]
Good (removed # from parent values):
2012-01-26 15:15:33,677 Trac[tracjsgantt] DEBUG: Computing WBS for (949, [4], 1) 2012-01-26 15:15:33,677 Trac[tracjsgantt] DEBUG: 949 has children [382, 948] 2012-01-26 15:15:33,677 Trac[tracjsgantt] DEBUG: Computing WBS for (948, [4, 1], 2)
I couldn't find the code where you strip the '#'. It used to be in tracjsgant.py. Thanks.
comment:13 Changed 13 years ago by
Replying to rozhi:
... I couldn't find the code where you strip the '#'. It used to be in tracjsgant.py. Thanks.
I refactored the shim-stuff out of tracjsgantt.py
to tracpm.py
a few revs ago. It has:
def postQuery(self, options, tickets): # Handle custom fields. # Clean up custom fields which might be null ('--') vs. blank ('') ... # Normalize parent field values. All parent values must be # done before building child lists, below. if self.isCfg('parent'): for t in tickets: # ChildTicketsPlugin puts '#' at the start of the # parent field. Strip it for simplicity. fieldName = self.fields[self.sources['parent']] parent = t[fieldName] if len(parent) > 0 and parent[0] == '#': t[fieldname] = parent[1:]
comment:14 Changed 13 years ago by
I'm using childticketplugin also. Is the parent field empty JSGantt works. Is parent field filled with a number for example #XXXX than it fails with error below.
Traceback (most recent call last): File "C:\Programme\Python25\lib\site-packages\trac-0.12.2-py2.5.egg\trac\wiki\formatter.py", line 717, in _macro_formatter return macro.process(args, in_paragraph=True) File "C:\Programme\Python25\lib\site-packages\trac-0.12.2-py2.5.egg\trac\wiki\formatter.py", line 304, in process text = self.processor(text) File "C:\Programme\Python25\lib\site-packages\trac-0.12.2-py2.5.egg\trac\wiki\formatter.py", line 291, in _macro_processor text) File "build\bdist.win32\egg\tracjsgantt\tracjsgantt.py", line 621, in expand_macro tasks = self._add_tasks(options) File "build\bdist.win32\egg\tracjsgantt\tracjsgantt.py", line 559, in _add_tasks self.pm.postQuery(options, self.tickets) File "build\bdist.win32\egg\tracjsgantt\tracpm.py", line 643, in postQuery t[fieldname] = parent[1:] NameError: global name 'fieldname' is not defined
I checked this part of coding and can't find any error. It's the part of coding in comment:#12. Do you have any idea?
didley
comment:16 follow-up: 17 Changed 13 years ago by
Replying to didley@gmx.de:
Sorry
I meant comment:13
I'm getting a different error. I haven't encountered your problem.
comment:17 Changed 13 years ago by
Replying to anonymous:
Replying to didley@gmx.de:
Sorry
I meant comment:13I'm getting a different error. I haven't encountered your problem.
I opened a new ticket. #9838
didley
comment:18 Changed 13 years ago by
Solved the problem. The problem occurs when the ChildTickets plugin is used with JsGantt, and a parent ticket has more than 1 children. The failure, with error message (KeyError: 'wbs'), happens because a wbs was not created for a ticket (a child).
Here is the patch:
--- a/0.11/tracjsgantt/tracpm.py Tue Feb 21 18:26:29 2012 -0800 +++ b/0.11/tracjsgantt/tracpm.py Tue Feb 21 18:30:38 2012 -0800 @@ -499,6 +499,15 @@ # # Milestones for the tickets are added pseudo-tickets. def postQuery(self, options, tickets): + + for t in tickets: + if self.isCfg('parent'): + # ChildTicketsPlugin puts '#' at the start of the + # parent field. Strip it for simplicity. + parent = t[self.fields['parent']] + if len(parent) > 0 and parent[0] == '#': + t[self.fields['parent']] = parent[1:] + for t in tickets: # Clean up custom fields which might be null ('--') vs. blank ('') nullable = [ 'pred', 'succ', @@ -516,11 +525,6 @@ # Clean up parent field, build list of children if self.isCfg('parent'): - # ChildTicketsPlugin puts '#' at the start of the - # parent field. Strip it for simplicity. - parent = t[self.fields['parent']] - if len(parent) > 0 and parent[0] == '#': - t[self.fields['parent']] = parent[1:] # An empty parent default so 0 (no such ticket) if t[self.fields['parent']] == '':
I moved the filtering/removal of '#', from the parent, in the beginning of postQuery, for all the tickets. The original code had it in an inner loop, but it was failing to find all the children for a parent, which later result in wbs not being created.
comment:19 Changed 13 years ago by
comment:20 Changed 13 years ago by
While not linked to this ticket, there were a number of changes recently that I think resulted in an equivalent fix (that is, it takes the #
clean up out of an inner loop). Please let me know if the current source works for you.
comment:21 Changed 12 years ago by
Resolution: | → fixed |
---|---|
Status: | assigned → closed |
Haven't heard back from the OP. Confirmed that the handling of '#' is earlier in PostQuery
.
Have you set the
parent_format
option? It defaults to '%s' but can be set to '#%s'. Looking now, I see that the exampleIs rather vague and unhelpful. I believe that you want is
in
trac.ini
but I have no good way to test it.