#441 closed defect (fixed)
0.10-incompatibility: Broken.
Reported by: | Owned by: | Alec Thomas | |
---|---|---|---|
Priority: | normal | Component: | TocMacro |
Severity: | normal | Keywords: | toc, formatter |
Cc: | Trac Release: | 0.10 |
Description
With Trac trunk (r3411) it stopped working with KeyError (check attached log). Code according to backtrace seems this section:
def _heading_formatter(self, match, fullmatch): ... anchor = self._anchors[-1] ...
I have modified it to the following (code taken from Trac Wiki formatter directly):
def _heading_formatter(self, match, fullmatch): ... anchor = fullmatch.group('hanchor') or '' ...
Seems to be working now. Hope this helps.
Attachments (8)
Change History (19)
Changed 18 years ago by
comment:1 follow-up: 2 Changed 18 years ago by
Replying to anonymous:
With Trac trunk (r3411) it stopped working with KeyError (check attached log).
Actually, this changed in [T3408].
def _heading_formatter(self, match, fullmatch): ... anchor = fullmatch.group('hanchor') or '' ...
No, that's not a correct fix. See the abovementioned change
for an example about how to get the anchor
.
The hanchor
group is for an optional, explicitely given id
,
which, most of the time, will not be given.
comment:2 Changed 18 years ago by
Changed 18 years ago by
comment:3 Changed 18 years ago by
You're right, I've just checked. Thanks. Will checkout latest TocMacro.
comment:4 Changed 18 years ago by
Whilst MyOutlineFormatter.format is being tweaked, purely as a clarification, the following three lines could be moved outside the enclosing for
loop:
36 active = '' 37 if page == active_page: 38 active = ' class="active"'
...since neither page
nor active_page
changes from one loop iteration to the next.
comment:5 Changed 18 years ago by
Trac Release: | 0.9 → 0.10 |
---|
comment:6 Changed 18 years ago by
cboos' macro.py suffers from inconsistent indentation schemes, and also, I think, introduces some bugs by accidentally shifting some statements to different block levels.
I've cleaned up the indentation and put the shifted statements back to their original block level, and am attaching the result as a patch....
Changed 18 years ago by
Attachment: | cboos-macro.py.patch added |
---|
The effective changes from cboos' macro.py, cleaned up and shown as a patch
comment:7 Changed 18 years ago by
Right, I remember I had trouble with the indentation, not sure why, as the original file seems to be correctly indented.
I could make a 0.10 version using your patch (+ the other change you suggested), if athomas would give me the perms for that plugin...
comment:8 Changed 18 years ago by
Summary: | Stopped working with trac trunk, error in using anchor → 0.10-incompatibility: Broken. |
---|
I've split up cboos' patch into multiple changes:
- fix441: Fix this ticket. (also, added the change I suggested in comment:4)
- tweaks: General refactoring.
- linewrap: Wrap overly long lines.
- wmbref: Convert to WikiMacroBase.
- 011notes: Add notes about 0.11.
(These should be applied in that order - they have interdependencies.)
Additionally, cboos' patch contained:
- Removal of trailing whitespace: I've not included that in the above patches, since it is easier for a committer to run a simple editor command, than review a patch doing the same (but it would be nice to have this done).
- Introduction of
coding: utf-8
statement: I've dropped that, since it was only there to support the addition of a weird angled quote character in an added comment, which looked like a typo anyway. - Placing of an assignment to
args
into anelse:
clause: I've removed this change, since it results inargs
being a different datatype (string vs. list) depending on whether args are provided, which doesn't seem right. - A couple of odd whitespace changes within lines: I left these out.
I will now attach the 5 patch files.
comment:9 Changed 18 years ago by
Oops! There's an error in various places throughout cboos' macro.py
and my derivatives:
out.write(system_message(MESSAGE), None)
is supposed to be:
out.write(system_message(MESSAGE, None))
The error is present in the first of two uses of system_message in macro.py
. In tweaks.patch
, I accidentally spread the error to the second use too. In linewrap.patch
, there's one change which isn't a pure line-wrap: the accidental spreading is undone again.
Rather than re-attaching fixed versions of tweaks.patch
and linewrap.patch
, please just correct the placement of the parentheses as described above, in tweaks.patch
and linewrap.patch
, before applying them - thanks!
comment:10 Changed 18 years ago by
Resolution: | → fixed |
---|---|
Status: | new → closed |
comment:11 Changed 18 years ago by
Yep, thanks for the fixes to my fixes, maxb :)
Also, the system_message
was slightly improved in [T3431].
Lastly, don't hesitate to comment and brainstorm further relative to the attachment:011notes.patch
Trac backtrace of TocMacro error