Edgewall Software
Modify

Opened 18 years ago

Closed 18 years ago

Last modified 18 years ago

#3692 closed enhancement (fixed)

[PATCH] - Enable Generic use of INavigationContributor

Reported by: ilias@… Owned by: Christian Boos
Priority: normal Milestone: 0.10
Component: project Version: 0.10b1
Severity: minor Keywords:
Cc: Branch:
Release Notes:
API Changes:
Internal Changes:

Description

The following code

implements(INavigationContributor)

def get_navigation_items(self, req):
    yield 'projnav', 'guide', html.a( 'Project Guide', href=self.env.href.wiki('ProjectGuide') )

crashes within source:/trunk/trac/web/chrome.py, as there's no Option "projnav_order" defined.

The attached patch enables that code without the need to define an Option.

This way, new custom navigation items can be generated dynamically, without any modifications in the source code / ini-files.

Attachments (2)

ChromeNavigationLinks.diff (1.3 KB ) - added by ilias@… 18 years ago.
ChromeNavigationLinksAttributeError.diff (1.3 KB ) - added by ilias@… 18 years ago.
corrected to catch only AttributeError

Download all attachments as: .zip

Change History (8)

by ilias@…, 18 years ago

Attachment: ChromeNavigationLinks.diff added

comment:1 by Christian Boos, 18 years ago

Owner: changed from daniel to Christian Boos
Severity: normalminor

A few (minor) remarks:

  • in attachment:ChromeNavigationLinks.diff, you used a "catch all" exception handler, which is generally a bad idea. Better be specific, in this case catching AttributeError is enough.
  • if you can, please directly provide us with a full-contained example component, in this case something like:
    from trac.core import *
    from trac.util.html import html
    from trac.web.chrome import INavigationContributor
    
    class ProjectNavigation(Component):
        implements(INavigationContributor)
    
        def get_active_navigation_item(self, req):
            return 'guide'
        
        def get_navigation_items(self, req):
            yield 'projnav', 'guide', \
                  html.a('Project Guide', href=req.href.wiki('ProjectGuide'))
    

Note also that you should get used to write req.href instead of self.env.href, as the latter form is now deprecated and will probably go away in 0.11.

As for the (fixed) patch itself, I'm +1 if you can show us how you intend to make use of the non-standard navigation category (i.e. something else than 'metanav' and 'mainnav').

comment:2 by Matthew Good, 18 years ago

Well, if we're going to support custom navigation items then they should probably support ordering as well. However, I don't want to keep pushing back 0.10 for new features. Can we at least push this to 0.10.1 to get some more information?

in reply to:  1 comment:3 by ilias@…, 18 years ago

Replying to cboos:

  • if you can, please directly provide us with a full-contained example component,

the code is located here (corrected to use "self.env.href"):

As for the (fixed) patch itself, I'm +1 if you can show us how you intend to make use of the non-standard navigation category (i.e. something else than 'metanav' and 'mainnav').

You can find an example usage here (menu below project title):

http://dev.lazaridis.com/base

I'll attach a corrected patch.

by ilias@…, 18 years ago

corrected to catch only AttributeError

in reply to:  2 comment:4 by ilias@…, 18 years ago

Replying to mgood:

Well, if we're going to support custom navigation items then they should probably support ordering as well. However, I don't want to keep pushing back 0.10 for new features. Can we at least push this to 0.10.1 to get some more information?

  • Custom navigation items are already supported. This patch removes just a tiny defect (possibly I should have filed a "defect" instead of "enhancement"), thus "custom navigation items" can be created again. This patch can/should be applied now, as it corrects the defect behaviour of the ordering-mechanism.
  • See #3695: The ordering mechanism could be refactored in order to avoid the necessity to hardcode the option within chrome.py. This should be implemented later, as it changes behaviour and would possibly block the 0.10 release.

comment:5 by Christian Boos, 18 years ago

Resolution: fixed
Status: newclosed

Implemented slightly differently in r3717.

comment:6 by ilias@…, 18 years ago

very nice, follow-up issue: #3704

Modify Ticket

Change Properties
Set your email in Preferences
Action
as closed The owner will remain Christian Boos.
The resolution will be deleted. Next status will be 'reopened'.
to The owner will be changed from Christian Boos to the specified user.

Add Comment


E-mail address and name can be saved in the Preferences .
 
Note: See TracTickets for help on using tickets.