[LNT][PATHCH] collect all directives from lnt.cfg

Chris Matthews chris.matthews at apple.com
Tue Jan 21 10:20:22 PST 2014


I’d like to propose LNT collect all configuration directives out of the lnt.cfg configuration file.  My motivation for this is that I have been developing experimental LNT functionality by building flask extensions out of tree, where they don’t break things.  Currently the LNT Config class looks for explicit keys in the config file, and adds those to the flask app config.  To allow out of tree modules to add configuration directives, I have patched config so that all directives in the file are added to the config object, making sure not to overwrite any that are there already.

diff --git a/lnt/server/config.py b/lnt/server/config.py
index 2e146b9fece5adb75cecbea65aa1899261940cb2..6bc5c4d5232332bc4be4e627e365ad2afacebb14 100644
--- a/lnt/server/config.py
+++ b/lnt/server/config.py
@@ -97,13 +97,20 @@ class Config:
 
         secretKey = data.get('secret_key', None)
 
-        return Config(data.get('name', 'LNT'), data['zorgURL'],
+        cfg = Config(data.get('name', 'LNT'), data['zorgURL'],
                       dbDir, os.path.join(baseDir, tempDir), secretKey,
                       dict([(k,DBInfo.fromData(dbDirPath, v,
                                                default_email_config))
                                      for k,v in data['databases'].items()]),
                       data.get('baselineRevision', '144168'))
-    
+
+        # Add any remaining keys to the config object.
+        for key, val in data.items():
+            if not hasattr(cfg, key):
+                setattr(cfg, key, val)
+        return cfg
+
+
     @staticmethod
     def dummyInstance():
         baseDir = tempfile.mkdtemp()  


-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20140121/0e8ce07b/attachment.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: extra_config_data.patch
Type: application/octet-stream
Size: 1068 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20140121/0e8ce07b/attachment.obj>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20140121/0e8ce07b/attachment-0001.html>


More information about the llvm-commits mailing list