summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJens Vagelpohl <jens@dataflake.org>2009-10-09 21:14:55 +0000
committerJens Vagelpohl <jens@dataflake.org>2009-10-09 21:14:55 +0000
commite174828dfe13eb0fa7be2f3ea3cd575a14226066 (patch)
tree396d791bace75791416c96e82b1c7e3bf4a88c70
parent74b02676f9b144479bf4a0eff814d90fbfdb3de5 (diff)
downloadProducts.MaildropHost-e174828dfe13eb0fa7be2f3ea3cd575a14226066.zip
Products.MaildropHost-e174828dfe13eb0fa7be2f3ea3cd575a14226066.tar.gz
- Feature: Added a method for extending the list of configuration
file paths programatically. (http://www.dataflake.org/tracker/issue_00649) git-svn-id: file:///svn-public/Products.MaildropHost/trunk@1815 835909ba-7c00-0410-bfa4-884f43845301
-rw-r--r--Products/MaildropHost/CHANGES.txt4
-rw-r--r--Products/MaildropHost/MaildropHost.py8
-rw-r--r--Products/MaildropHost/tests/test_MaildropHost.py17
3 files changed, 28 insertions, 1 deletions
diff --git a/Products/MaildropHost/CHANGES.txt b/Products/MaildropHost/CHANGES.txt
index ef37290..07a37e9 100644
--- a/Products/MaildropHost/CHANGES.txt
+++ b/Products/MaildropHost/CHANGES.txt
@@ -4,6 +4,10 @@ MaildropHost change log
2.3 (unreleased)
----------------
+- Feature: Added a method for extending the list of configuration
+ file paths programatically.
+ (http://www.dataflake.org/tracker/issue_00649)
+
2.2 (2009-05-29)
----------------
diff --git a/Products/MaildropHost/MaildropHost.py b/Products/MaildropHost/MaildropHost.py
index c6db363..c12714d 100644
--- a/Products/MaildropHost/MaildropHost.py
+++ b/Products/MaildropHost/MaildropHost.py
@@ -130,7 +130,13 @@ class MaildropHost(MailHost):
# Persist the new path, and then reload the configuration
self.config_path = CONFIG_PATHS.get(path_key)
self._load_config()
-
+
+ security.declareProtected(change_configuration, 'addConfigPath')
+ def addConfigPath(self, path_key, path):
+ """ Method to add a config path programmatically
+ """
+ CONFIG_PATHS[path_key] = path
+
security.declareProtected(change_configuration, 'getCandidateConfigPaths')
def getCandidateConfigPaths(self):
""" Retrieve the config paths set in zope.conf
diff --git a/Products/MaildropHost/tests/test_MaildropHost.py b/Products/MaildropHost/tests/test_MaildropHost.py
index b958b4e..a226b94 100644
--- a/Products/MaildropHost/tests/test_MaildropHost.py
+++ b/Products/MaildropHost/tests/test_MaildropHost.py
@@ -173,6 +173,23 @@ class MaildropHostTests(unittest.TestCase):
# cleanup
CONFIG_PATHS = old_config_paths
+ def testAddConfigPathMethod(self):
+ from Products.MaildropHost.MaildropHost import CONFIG_PATHS
+ old_config_paths = CONFIG_PATHS.copy()
+ mdh = self._makeOne('MDH', 'MDH Title')
+ candidates = mdh.getCandidateConfigPaths()
+ # config paths may have been added elsewhere
+ num_current_paths = len(candidates)
+ config_path = '/a/system/path'
+ mdh.addConfigPath('program_path', config_path)
+ candidates = mdh.getCandidateConfigPaths()
+ self.assertEquals(len(candidates), num_current_paths + 1)
+ self.failUnless('program_path' in [x[0] for x in candidates])
+ self.assertEquals(CONFIG_PATHS['program_path'], config_path)
+
+ # cleanup
+ CONFIG_PATHS = old_config_paths
+
def test_suite():
return unittest.TestSuite((