changeset 35:321fe58a9eae

flush out validate function
author Jeff Hammel <jhammel@mozilla.com>
date Tue, 27 Mar 2012 09:35:21 -0700
parents 79aca36abd9a
children d218df4d0b4c
files configuration/config.py
diffstat 1 files changed, 10 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/configuration/config.py	Tue Mar 27 09:30:56 2012 -0700
+++ b/configuration/config.py	Tue Mar 27 09:35:21 2012 -0700
@@ -189,6 +189,16 @@
 
     def validate(self):
         """validate resultant configuration"""
+        for key, value in self.options.items():
+            if key not in self.config:
+                required = value.get('required')
+                if required:
+                    if isinstance(required, basestring):
+                        required_message = required
+                    else:
+                        required_message = "Parameter %s is required but not present" % key
+                    # TODO: more specific exception
+                    raise Exception(required_message)
         # TODO: configuration should be locked after this is called
 
     ### methods for adding configuration