You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@bloodhound.apache.org by Apache Bloodhound <bl...@incubator.apache.org> on 2012/06/18 18:47:24 UTC
Re: [Apache Bloodhound] #3: Multi Product NavigationContributor
implementation modifications
#3: Multi Product NavigationContributor implementation modifications
---------------------------+-------------------------------------
Reporter: gjm | Owner: gjm
Type: task | Status: accepted
Priority: major | Milestone: RC1 for initial release
Component: multiproduct | Version:
Resolution: | Keywords:
---------------------------+-------------------------------------
Changes (by gjm):
* priority: blocker => major
Comment:
It looks like this is possible to deal with by modifying paths in a post
process request:
{{{
#!diff
Index: multiproduct/web_ui.py
===================================================================
--- multiproduct/web_ui.py (revision 1351401)
+++ multiproduct/web_ui.py (working copy)
@@ -23,6 +23,7 @@
import re
from genshi.builder import tag
+from genshi.core import Attrs, QName
from trac.core import Component, implements, TracError
from trac.web.chrome import (add_link, add_notice, add_warning,
prevnext_nav,
@@ -40,7 +41,10 @@
"""Base Product behaviour"""
implements(IRequestFilter, IRequestHandler, INavigationContributor)
-
+ NAVITEM_DO_NOT_TRANSFORM = [ '/login',
+ '/logout',
+ '/products',
+ ]
def get_active_navigation_item(self, req):
return 'products'
@@ -96,6 +100,28 @@
def post_process_request(self, req, template, data, content_type):
"""post process request filter"""
+ # update the nav item links
+ root = req.href()
+ rootproducts = req.href.products()
+ pid = req.args.get('productid')
+ if pid:
+ for navkey, section in req.chrome['nav'].iteritems():
+ for item in section:
+ try:
+ href = item['label'].attrib.get('href')
+ except AttributeError:
+ continue
+ if href.startswith(rootproducts):
+ continue
+ if href.startswith(root):
+ tail = href[len(root):]
+ if tail not in self.NAVITEM_DO_NOT_TRANSFORM:
+ attrs = [attr for attr in
item['label'].attrib
+ if attr[0] != 'href']
+ newhref = req.href.products(pid, tail)
+ item['label'].attrib = Attrs([(QName('href'),
+ newhref)] +
attrs)
+
return (template, data, content_type)
# IRequestHandler methods
}}}
--
Ticket URL: <https://issues.apache.org/bloodhound/ticket/3#comment:3>
Apache Bloodhound <https://issues.apache.org/bloodhound/>
The Apache Bloodhound (incubating) issue tracker