From 183a459c3f495a597168e7d4fb3551585e5b91a9 Mon Sep 17 00:00:00 2001 From: Brad Aagaard Date: Thu, 30 Jun 2016 08:39:56 -0700 Subject: [PATCH] Fix premature validation for properties. Properties should validate in _validate(), not in _set(), so that we can get help, version info, etc. This appears to be the intent because Executive.verifyConfiguration() will call _validate() and nicely prints all of the errors, not just the first one. --- pyre/inventory/Configurable.py | 20 +++++--------------- pyre/inventory/Property.py | 5 ++--- 2 files changed, 7 insertions(+), 18 deletions(-) diff --git a/pyre/inventory/Configurable.py b/pyre/inventory/Configurable.py index e24dd36..97398a1 100644 --- a/pyre/inventory/Configurable.py +++ b/pyre/inventory/Configurable.py @@ -68,23 +68,13 @@ def updateConfiguration(self, registry): def applyConfiguration(self, context=None): """transfer user settings to my inventory""" - try: - - if context is None: - context = self.newConfigContext() + if context is None: + context = self.newConfigContext() - context.configureComponent(self) + context.configureComponent(self) - # give descendants a chance to adjust to configuration changes - self._configure() - - - except ValueError, err: - aliases = ", ".join(self.aliases) - raise ValueError("%s\nBacktrace - Component %s" % (err.message, aliases)) - except RuntimeError, err: - aliases = ", ".join(self.aliases) - raise RuntimeError("%s\nBacktrace - Component %s" % (err.message, aliases)) + # give descendants a chance to adjust to configuration changes + self._configure() return context diff --git a/pyre/inventory/Property.py b/pyre/inventory/Property.py index 54adf41..23bf117 100644 --- a/pyre/inventory/Property.py +++ b/pyre/inventory/Property.py @@ -48,9 +48,6 @@ def _getDefaultValue(self, instance): if value is not None: # convert value = self._cast(value) - # validate - if self.validator: - value = self.validator(value) import pyre.parsing.locators locator = pyre.parsing.locators.default() @@ -63,6 +60,8 @@ def _cast(self, input): def _validate(self, value): + if self.validator: + value = self.validator(value) return value