TracBackLinkPlugin - TypeError: 'Fragment' object is not callable

39 views
Skip to first unread message

Clemens Feige

unread,
Jan 18, 2021, 7:48:55 PM1/18/21
to Trac Users
Hello

After upgrading my site from TRAC 1.2.3 to 1.4.2 the TracBackLinkPlugin
is causing mysterious "Trac Oops" errors when viewing some ticket or
wiki pages (but only on some of them).

https://trac-hacks.org/wiki/TracBackLinkPlugin

The particular error message is as follow:

Oops...
Trac detected an internal error:
TypeError: 'Fragment' object is not callable

Surprising this error does not trigger on all tickets or wiki pages.
Only some of them cause the error (maybe 25% of them).
Other tickets and wiki page work fine and I can see the desired "Back
Link" box. This tells me that the plugin is basically working. So far I
could not see a pattern.

I have been using this plugin (older version) for years with great
success on our old TRAC 1.2 But now I upgraded our TRAC to 1.4.2 and
also upgraded the plugin and the problem started.

I need your help, please.

--------------
Of course I have execute the required upgrade and sync-command to
populate the database table:

trac-admin <REPO> upgrade
trac-admin <REPO> backlink sync


---------------
I am running TRAC 1.4.2.
No other plugins are enabled.

TracBackLinkPlugin
version is 1.0.12 [17951 by jun66j5]

I also tested an earlier version, which also fails.
version 1.0.11 [17948 by jun66j5]

--------------

Python Traceback

File "/usr/local/lib/python2.7/dist-packages/trac/web/main.py", line
639, in dispatch_request
dispatcher.dispatch(req)
File "/usr/local/lib/python2.7/dist-packages/trac/web/main.py", line
252, in dispatch
resp = self._post_process_request(req, *resp)
File "/usr/local/lib/python2.7/dist-packages/trac/web/main.py", line
495, in _post_process_request
resp = f.post_process_request(req, *resp[:-1])
File "/usr/local/lib/python2.7/dist-packages/tracbacklink/web_ui.py",
line 100, in post_process_request
if type_ else None
File "/usr/local/lib/python2.7/dist-packages/tracbacklink/web_ui.py",
line 156, in _get_backlinks_content
rendered = self._render_backlinks(req, sources)
File "/usr/local/lib/python2.7/dist-packages/tracbacklink/web_ui.py",
line 206, in _render_backlinks
rendered.update(f(req, sources))
File "/usr/local/lib/python2.7/dist-packages/tracbacklink/web_ui.py",
line 323, in _render_repository_backlinks
rendered(' ' if idx else u' \u2013 ', item)

Above error is for a ticket and points to:
_render_ticket_backlinks

https://trac-hacks.org/browser/tracbacklinkplugin/1.0/tracbacklink/web_ui.py#L250

... but the error may also appear when viewing a wiki page:
_render_wiki_backlinks

https://trac-hacks.org/browser/tracbacklinkplugin/1.0/tracbacklink/web_ui.py#L209



I would appreciate any help or comments on this matter.
The TracBackLinkPlugin is very valuable and I would love to use it on
our site.

Best regards
Clemens

Ryan Ollos

unread,
Jan 18, 2021, 7:56:02 PM1/18/21
to Trac Users
I'm not sure about the cause, but I would open a ticket for the plugin:

Jun Omae

unread,
Jan 18, 2021, 10:06:58 PM1/18/21
to trac-...@googlegroups.com
Thanks for the reporting. Reopened
https://trac-hacks.org/ticket/13619#comment:9.
It seems to be caused by that Fragment in genshi has __call__() method
but Fragment in trac 1.4 doesn't.
--
Jun Omae <jun...@gmail.com> (大前 潤)

Jun Omae

unread,
Jan 18, 2021, 10:39:35 PM1/18/21
to trac-...@googlegroups.com
Could you please try the attached patch?
tracbacklinkplugin-r17954.diff

Clemens Feige

unread,
Jan 19, 2021, 4:07:56 AM1/19/21
to trac-...@googlegroups.com
Dear Jun

Your patch is working.
Very well done (and so fast)!

Many thanks
Clemens

RjOllos

unread,
Jan 19, 2021, 12:48:57 PM1/19/21
to Trac Users
On Monday, January 18, 2021 at 7:06:58 PM UTC-8 Jun Omae wrote:
Thanks for the reporting. Reopened
https://trac-hacks.org/ticket/13619#comment:9.
It seems to be caused by that Fragment in genshi has __call__() method
but Fragment in trac 1.4 doesn't.

Should we add the __call__() method to Fragment in trac/util/html.py? 

Jun Omae

unread,
Jan 21, 2021, 4:34:12 AM1/21/21
to trac-...@googlegroups.com
Yes. It would be to improve compatibility with Fragment in Genshi library.

The Fragment.__call__() in Genshi accepts multiple arguments and each
argument is passed to Fragment.append(). Fragment.append() accepts
only 1 argument.
Message has been deleted

RjOllos

unread,
Jan 21, 2021, 12:16:29 PM1/21/21
to Trac Users
Reply all
Reply to author
Forward
0 new messages