#1571 closed defect (fixed)
Cannot add custom plugins that implement INavigationContributor
Reported by: | ebcom | Owned by: | Christopher Lenz |
---|---|---|---|
Priority: | normal | Milestone: | 0.9 |
Component: | general | Version: | devel |
Severity: | normal | Keywords: | |
Cc: | chris@… | Branch: | |
Release Notes: | |||
API Changes: | |||
Internal Changes: |
Description
In chrome.py
, line 146
items.sort(lambda x,y: cmp(order.index(x[0]), order.index(y[0])))
fails to execute with the following dump:
Traceback (most recent call last): File "D:\tmp\trac\current\Lib\site-packages\trac\web\standalone.py", line 213, in _do_trac_req dispatch_request(path_info, req, env) File "D:\tmp\trac\current\Lib\site-packages\trac\web\main.py", line 419, in dispatch_request dispatcher.dispatch(req) File "D:\tmp\trac\current\Lib\site-packages\trac\web\main.py", line 276, in dispatch chrome.populate_hdf(req, chosen_handler) File "D:\tmp\trac\current\Lib\site-packages\trac\web\chrome.py", line 146, in populate_hdf items.sort(lambda x,y: cmp(order.index(x[0]), order.index(y[0]))) File "D:\tmp\trac\current\Lib\site-packages\trac\web\chrome.py", line 146, in <lambda> items.sort(lambda x,y: cmp(order.index(x[0]), order.index(y[0]))) ValueError: list.index(x): x not in list
This error comes from the fact that navigation.items()
contains statically defined items (categories: mainnav and metanav). These items are defined in trac.ini
.
When the user adds a plugin that provides a navigation item, this item is not automatically registered into the appropriate category. This makes the sort method fail as the new navigation item is not part of the list.
Perharps this is not really a bug, if the plugin is expected to be registered into the appropriate trac.ini
[trac] section.
However, I don't understand why the same information is duplicated:
- in the plugin python code, where
get_navigation_items
should return the navigation category as the first item - in the
trac.ini
file, where it should be statically added to the same navigation category
Attachments (0)
Change History (3)
comment:1 by , 19 years ago
comment:2 by , 19 years ago
Status: | new → assigned |
---|
comment:3 by , 19 years ago
Resolution: | → fixed |
---|---|
Status: | assigned → closed |
This should be fixed in [1695].
To answer your question: the trac/mainnav and trac/metanav options are not for registering navigation contributors, it's for defining the order in which nav items appear. If a navigation item is not in the respective list, it just gets appended at the end.
sorry about emails: eblot and ebcom are the same person: myself ;-)