Modify

Opened 18 years ago

Closed 18 years ago

Last modified 18 years ago

#441 closed defect (fixed)

0.10-incompatibility: Broken.

Reported by: Dinko Korunic <dinko.korunic@…> 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)

trac.log (1.5 KB) - added by Dinko Korunic <dinko.korunic@…> 18 years ago.
Trac backtrace of TocMacro error
macro.py (7.5 KB) - added by Christian Boos 18 years ago.
TocMacro's macro.py file updated for 0.10. Time to make a new branch for it! The macro has not been thoroughly tested, but this appears to work. Compatible with [T3412]. (take 2)
cboos-macro.py.patch (8.3 KB) - added by Max Bowsher 18 years ago.
The effective changes from cboos' macro.py, cleaned up and shown as a patch
fix441.patch (2.1 KB) - added by Max Bowsher 18 years ago.
See comment:8
tweaks.patch (2.5 KB) - added by Max Bowsher 18 years ago.
See comment:8
linewrap.patch (3.2 KB) - added by Max Bowsher 18 years ago.
See comment:8
wmbref.patch (1.5 KB) - added by Max Bowsher 18 years ago.
See comment:8
011notes.patch (1.7 KB) - added by Max Bowsher 18 years ago.
See comment:8

Download all attachments as: .zip

Change History (19)

Changed 18 years ago by Dinko Korunic <dinko.korunic@…>

Attachment: trac.log added

Trac backtrace of TocMacro error

comment:1 in reply to:  description ; Changed 18 years ago by anonymous

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 in reply to:  1 Changed 18 years ago by Christian Boos

Replying to anonymous: ... That anonymous was me (and the above comment made me spot a little bug with the reply to description feature, which I just fixed [T3412])

Changed 18 years ago by Christian Boos

Attachment: macro.py added

TocMacro's macro.py file updated for 0.10. Time to make a new branch for it! The macro has not been thoroughly tested, but this appears to work. Compatible with [T3412]. (take 2)

comment:3 Changed 18 years ago by Dinko Korunic <dinko.korunic@…>

You're right, I've just checked. Thanks. Will checkout latest TocMacro.

comment:4 Changed 18 years ago by Max Bowsher

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 Max Bowsher

Trac Release: 0.90.10

comment:6 Changed 18 years ago by Max Bowsher

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 Max Bowsher

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 Christian Boos

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 Max Bowsher

Summary: Stopped working with trac trunk, error in using anchor0.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 an else: clause: I've removed this change, since it results in args 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.

Changed 18 years ago by Max Bowsher

Attachment: fix441.patch added

See comment:8

Changed 18 years ago by Max Bowsher

Attachment: tweaks.patch added

See comment:8

Changed 18 years ago by Max Bowsher

Attachment: linewrap.patch added

See comment:8

Changed 18 years ago by Max Bowsher

Attachment: wmbref.patch added

See comment:8

Changed 18 years ago by Max Bowsher

Attachment: 011notes.patch added

See comment:8

comment:9 Changed 18 years ago by Max Bowsher

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 Noah Kantrowitz

Resolution: fixed
Status: newclosed

(In [927]) Intergrating several patches from #441. Thanks to cboos and maxb for sorting this out. Closes #441.

comment:11 Changed 18 years ago by Christian Boos

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

Modify Ticket

Change Properties
Set your email in Preferences
Action
as closed The owner will remain Alec Thomas.
The resolution will be deleted. Next status will be 'reopened'.

Add Comment


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

 
Note: See TracTickets for help on using tickets.