incubator-bloodhound-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From j...@apache.org
Subject svn commit: r1438016 - in /incubator/bloodhound/branches/bep_0003_multiproduct/bloodhound_multiproduct/multiproduct: api.py env.py
Date Thu, 24 Jan 2013 14:31:43 GMT
Author: jure
Date: Thu Jan 24 14:31:43 2013
New Revision: 1438016

URL: http://svn.apache.org/viewvc?rev=1438016&view=rev
Log:
#115, patch t115_r1437383_inherit_product_config.diff, shared product settings (from Olemis)


Modified:
    incubator/bloodhound/branches/bep_0003_multiproduct/bloodhound_multiproduct/multiproduct/api.py
    incubator/bloodhound/branches/bep_0003_multiproduct/bloodhound_multiproduct/multiproduct/env.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=1438016&r1=1438015&r2=1438016&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
Thu Jan 24 14:31:43 2013
@@ -22,6 +22,7 @@ from datetime import datetime
 from genshi.builder import tag
 
 from pkg_resources import resource_filename
+from trac.config import PathOption
 from trac.core import Component, TracError, implements
 from trac.db import Table, Column, DatabaseManager, Index
 from trac.env import IEnvironmentSetupParticipant
@@ -39,10 +40,16 @@ PLUGIN_NAME = 'Bloodhound multi product'
 
 class MultiProductSystem(Component):
     """Creates the database tables and template directories"""
-    
+
     implements(IEnvironmentSetupParticipant, ITemplateProvider,
             IPermissionRequestor, ITicketFieldProvider, IResourceManager)
-    
+
+    product_config_parent = PathOption('inherit', 'multiproduct', '',
+        """The path to the configuration file containing the settings shared
+        by sibling product environments. By default will inherit 
+        global environment configuration.
+        """)
+
     SCHEMA = [mcls._get_schema() \
               for mcls in (Product, ProductResourceMap)]
 
@@ -52,16 +59,16 @@ class MultiProductSystem(Component):
             SELECT value FROM system WHERE name = %s
             """, (DB_SYSTEM_KEY,))
         return int(rows[0][0]) if rows else -1
-    
+
     # IEnvironmentSetupParticipant methods
     def environment_created(self):
         """Insertion of any default data into the database."""
         self.log.debug("creating environment for %s plugin." % PLUGIN_NAME)
-    
+
     def environment_needs_upgrade(self, db_dummy=None):
         """Detects if the installed db version matches the running system"""
         db_installed_version = self.get_version()
-        
+
         if db_installed_version > DB_VERSION:
             raise TracError('''Current db version (%d) newer than supported by
             this version of the %s (%d).''' % (db_installed_version,
@@ -207,7 +214,7 @@ class MultiProductSystem(Component):
     def get_templates_dirs(self):
         """provide the plugin templates"""
         return [resource_filename(__name__, 'templates')]
-    
+
     def get_htdocs_dirs(self):
         """proved the plugin htdocs"""
         return []
@@ -223,7 +230,7 @@ class MultiProductSystem(Component):
         """Product select fields"""
         return [(35, {'name': 'product', 'label': N_('Product'),
                       'cls': Product, 'pk': 'prefix', 'optional': True})]
-    
+
     def get_radio_fields(self):
         """Product radio fields"""
         return []

Modified: incubator/bloodhound/branches/bep_0003_multiproduct/bloodhound_multiproduct/multiproduct/env.py
URL: http://svn.apache.org/viewvc/incubator/bloodhound/branches/bep_0003_multiproduct/bloodhound_multiproduct/multiproduct/env.py?rev=1438016&r1=1438015&r2=1438016&view=diff
==============================================================================
--- incubator/bloodhound/branches/bep_0003_multiproduct/bloodhound_multiproduct/multiproduct/env.py
(original)
+++ incubator/bloodhound/branches/bep_0003_multiproduct/bloodhound_multiproduct/multiproduct/env.py
Thu Jan 24 14:31:43 2013
@@ -29,6 +29,7 @@ from trac.util.compat import sha1
 from trac.versioncontrol import RepositoryManager
 from trac.web.href import Href
 
+from multiproduct.api import MultiProductSystem
 from multiproduct.config import Configuration
 from multiproduct.model import Product
 from multiproduct.dbcursor import BloodhoundIterableCursor
@@ -451,8 +452,14 @@ class ProductEnvironment(Component, Comp
     def setup_config(self):
         """Load the configuration object.
         """
-        # FIXME: Inherit global environment setting ?
-        self.config = Configuration(self.parent, self.product.prefix)
+        import trac.config
+
+        parent_path = MultiProductSystem(self.parent).product_config_parent
+        if parent_path and os.path.isfile(parent_path):
+            parents = [trac.config.Configuration(parent_path)]
+        else:
+            parents = [self.parent.config]
+        self.config = Configuration(self.parent, self.product.prefix, parents)
         self.setup_log()
 
     def setup_log(self):



Mime
View raw message