bloodhound-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From j...@apache.org
Subject svn commit: r1455576 - in /incubator/bloodhound/branches/bep_0003_multiproduct/bloodhound_multiproduct/multiproduct: api.py hooks.py web_ui.py
Date Tue, 12 Mar 2013 15:15:22 GMT
Author: jure
Date: Tue Mar 12 15:15:22 2013
New Revision: 1455576

URL: http://svn.apache.org/r1455576
Log:
Renamed default product to '@', redirect most URL requests targeted to global environment
to default product


Modified:
    incubator/bloodhound/branches/bep_0003_multiproduct/bloodhound_multiproduct/multiproduct/api.py
    incubator/bloodhound/branches/bep_0003_multiproduct/bloodhound_multiproduct/multiproduct/hooks.py
    incubator/bloodhound/branches/bep_0003_multiproduct/bloodhound_multiproduct/multiproduct/web_ui.py

Modified: incubator/bloodhound/branches/bep_0003_multiproduct/bloodhound_multiproduct/multiproduct/api.py
URL: http://svn.apache.org/viewvc/incubator/bloodhound/branches/bep_0003_multiproduct/bloodhound_multiproduct/multiproduct/api.py?rev=1455576&r1=1455575&r2=1455576&view=diff
==============================================================================
--- incubator/bloodhound/branches/bep_0003_multiproduct/bloodhound_multiproduct/multiproduct/api.py
(original)
+++ incubator/bloodhound/branches/bep_0003_multiproduct/bloodhound_multiproduct/multiproduct/api.py
Tue Mar 12 15:15:22 2013
@@ -42,12 +42,14 @@ from trac.wiki.parser import WikiParser
 from multiproduct.model import Product, ProductResourceMap, ProductSetting
 from multiproduct.util import EmbeddedLinkFormatter, IDENTIFIER
 
-__all__ = 'MultiProductSystem', 'PRODUCT_SYNTAX_DELIMITER'
+__all__ = ['MultiProductSystem', 'PRODUCT_SYNTAX_DELIMITER', 'DEFAULT_PRODUCT']
 
 DB_VERSION = 4
 DB_SYSTEM_KEY = 'bloodhound_multi_product_version'
 PLUGIN_NAME = 'Bloodhound multi product'
 
+DEFAULT_PRODUCT = '@'
+
 class ISupportMultiProductEnvironment(Interface):
     """Extension point interface for components that are aware of multi
     product environment and its specifics.
@@ -100,7 +102,6 @@ class MultiProductSystem(Component):
                       'report',
                       ]
 
-
     def get_version(self):
         """Finds the current version of the bloodhound database schema"""
         rows = self.env.db_direct_query("""
@@ -170,7 +171,6 @@ class MultiProductSystem(Component):
                 from multiproduct.model import Product
                 import trac.db_default
 
-                DEFAULT_PRODUCT = 'default'
                 TICKET_TABLES = ['ticket_change', 'ticket_custom',
                                  'attachment',
                                 ]
@@ -230,9 +230,9 @@ class MultiProductSystem(Component):
                 for table in self.MIGRATE_TABLES:
                     temp_table_name, cols = create_temp_table(table)
                     if table == 'wiki':
-                        self.log.info("Populating table '%s'", table)
-                        db("INSERT INTO %s (%s, product) SELECT %s,'' FROM %s" %
-                           (table, cols, cols, temp_table_name))
+                        self.log.info("Migrating wiki to default product")
+                        db("INSERT INTO %s (%s, product) SELECT %s,'%s' FROM %s" %
+                           (table, cols, cols, DEFAULT_PRODUCT, temp_table_name))
                     else:
                         products = Product.select(self.env)
                         for product in products:

Modified: incubator/bloodhound/branches/bep_0003_multiproduct/bloodhound_multiproduct/multiproduct/hooks.py
URL: http://svn.apache.org/viewvc/incubator/bloodhound/branches/bep_0003_multiproduct/bloodhound_multiproduct/multiproduct/hooks.py?rev=1455576&r1=1455575&r2=1455576&view=diff
==============================================================================
--- incubator/bloodhound/branches/bep_0003_multiproduct/bloodhound_multiproduct/multiproduct/hooks.py
(original)
+++ incubator/bloodhound/branches/bep_0003_multiproduct/bloodhound_multiproduct/multiproduct/hooks.py
Tue Mar 12 15:15:22 2013
@@ -52,6 +52,9 @@ class ProductizedHref(Href):
                           'logout',
                           'prefs',
                           'products',
+                          'verify_email',
+                          'reset_password',
+                          'register',
                           ]
     STATIC_PREFIXES = ['js/',
                        'css/',

Modified: incubator/bloodhound/branches/bep_0003_multiproduct/bloodhound_multiproduct/multiproduct/web_ui.py
URL: http://svn.apache.org/viewvc/incubator/bloodhound/branches/bep_0003_multiproduct/bloodhound_multiproduct/multiproduct/web_ui.py?rev=1455576&r1=1455575&r2=1455576&view=diff
==============================================================================
--- incubator/bloodhound/branches/bep_0003_multiproduct/bloodhound_multiproduct/multiproduct/web_ui.py
(original)
+++ incubator/bloodhound/branches/bep_0003_multiproduct/bloodhound_multiproduct/multiproduct/web_ui.py
Tue Mar 12 15:15:22 2013
@@ -35,9 +35,10 @@ from trac.web.main import RequestDispatc
 
 from multiproduct.model import Product
 from multiproduct.util import ProductDelegate
-
+from multiproduct.api import DEFAULT_PRODUCT
 
 PRODUCT_RE = re.compile(r'^/products/(?P<pid>[^/]*)(?P<pathinfo>.*)')
+REDIRECT_DEFAULT_RE = re.compile(r'^/(?P<section>milestone|roadmap|query|report|newticket|ticket|wiki|qct|timeline|(raw-|zip-)?attachment|diff|batchmodify|search)(?P<pathinfo>.*)')
 
 class ProductModule(Component):
     """Base Product behaviour"""
@@ -60,19 +61,19 @@ class ProductModule(Component):
     def pre_process_request(self, req, handler):
         """pre process request filter"""
         pid = None
-        match = PRODUCT_RE.match(req.path_info)
-        if match:
+        product_match = PRODUCT_RE.match(req.path_info)
+        if product_match:
             dispatcher = self.env[RequestDispatcher]
             if dispatcher is None:
                 raise TracError('Unable to load RequestDispatcher.')
-            pid = match.group('pid')
-        
+            pid = product_match.group('pid')
+
         if pid:
             products = Product.select(self.env, where={'prefix': pid})
             if pid and len(products) == 1:
                 req.args['productid'] = pid
                 req.args['product'] = products[0].name
-                if handler is self and match.group('pathinfo') not in ('', '/'):
+                if handler is self and product_match.group('pathinfo') not in ('', '/'):
                     # select a new handler
                     environ = req.environ.copy()
                     pathinfo = environ['PATH_INFO'].split('/')
@@ -97,7 +98,7 @@ class ProductModule(Component):
                     # the newreq.args below caused a re-evaluation, thus a deadlock.
                     # The fix is to copy the args from the old request to the new one.
                     setattr(newreq, 'args', req.args)
-                    
+
                     new_handler = None
                     for hndlr in dispatcher.handlers:
                         if hndlr is not self and hndlr.match_request(newreq):
@@ -116,7 +117,17 @@ class ProductModule(Component):
             else:
                 raise ResourceNotFound(_("Product %(id)s does not exist.", 
                                          id=pid), _("Invalid product id"))
-        
+        else:
+            redirect_match = REDIRECT_DEFAULT_RE.match(req.path_info)
+            if redirect_match:
+                target = req.href.products(DEFAULT_PRODUCT,
+                                           redirect_match.group('section'),
+                                           redirect_match.group('pathinfo') \
+                                               if redirect_match.group('pathinfo') else None)
+                if req.query_string:
+                    target += '?' + req.query_string
+                req.redirect(target, permanent=True)
+
         return handler
     
     def post_process_request(self, req, template, data, content_type):



Mime
View raw message