Olemis Lang avatar Olemis Lang committed 9803455

BH Multiproduct #115 : Shared product settings

Comments (0)

Files changed (2)

+t115/t115_r1437383_inherit_product_config.diff
 t115/t115_r1436300_option_accessor.diff
 #t333/t333_r1427886_schema_autoinc.diff
 #t333/t333_r1427886_mp_gen_schema.diff

t115/t115_r1437383_inherit_product_config.diff

+# HG changeset patch
+# Parent 6d8eb9a53b0f3382d008d30a7e4a36ee26f2d0fd
+BH Multiproduct #115 : Shared product settings
+
+diff -r 6d8eb9a53b0f bloodhound_multiproduct/multiproduct/api.py
+--- a/bloodhound_multiproduct/multiproduct/api.py	Wed Jan 23 13:24:12 2013 +0000
++++ b/bloodhound_multiproduct/multiproduct/api.py	Wed Jan 23 22:39:23 2013 -0500
+@@ -22,6 +22,7 @@
+ 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 @@
+ 
+ class MultiProductSystem(Component):
+     """Creates the database tables and template directories"""
+-    
++
+     implements(IEnvironmentSetupParticipant, ITemplateProvider,
+             IPermissionRequestor, ITicketFieldProvider, IResourceManager)
+-    
++
++    product_config_parent = PathOption('inherit', 'multiproduct', 'trac.ini',
++        """The path to the configuration file containing the settings shared
++        by sibling product environments. By default it will be the path to
++        the configuration file of the global environment (i.e. trac.ini).
++        """)
++
+     SCHEMA = [mcls._get_schema() \
+               for mcls in (Product, ProductResourceMap)]
+ 
+@@ -52,16 +59,16 @@
+             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,
+@@ -203,7 +210,7 @@
+     def get_templates_dirs(self):
+         """provide the plugin templates"""
+         return [resource_filename(__name__, 'templates')]
+-    
++
+     def get_htdocs_dirs(self):
+         """proved the plugin htdocs"""
+         return []
+@@ -219,7 +226,7 @@
+         """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 []
+diff -r 6d8eb9a53b0f bloodhound_multiproduct/multiproduct/env.py
+--- a/bloodhound_multiproduct/multiproduct/env.py	Wed Jan 23 13:24:12 2013 +0000
++++ b/bloodhound_multiproduct/multiproduct/env.py	Wed Jan 23 22:39:23 2013 -0500
+@@ -29,6 +29,7 @@
+ 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,12 @@
+     def setup_config(self):
+         """Load the configuration object.
+         """
+-        # FIXME: Inherit global environment setting ?
+-        self.config = Configuration(self.parent, self.product.prefix)
++        parent = MultiProductSystem(self.parent).product_config_parent
++        if parent and os.path.isfile(parent):
++            parents = [parent]
++        else:
++            parents = None
++        self.config = Configuration(self.parent, self.product.prefix, parents)
+         self.setup_log()
+ 
+     def setup_log(self):
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.