summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorVishwanatha Subbanna <vishwa@linux.vnet.ibm.com>2016-09-20 20:41:15 +0530
committerPatrick Williams <patrick@stwcx.xyz>2016-09-27 18:42:37 +0000
commit0722564e32b749e484dd64461817d9ce1374e2b6 (patch)
tree322b10697a5feddf49126eefe31dcf1a9b02bf5c
parentb00a989bc4e0a7148be28af818d29395e62f92c0 (diff)
downloadpyphosphor-0722564e32b749e484dd64461817d9ce1374e2b6.tar.gz
pyphosphor-0722564e32b749e484dd64461817d9ce1374e2b6.zip
Callback input validator function on property set
This will provide a way for subclasses to register a callback handler which will then be called into whenever a property update is attempted. The callback will validate the user inputs and then either throw exception or return success. On an exception, its rethrown. Change-Id: I4c1920adb7e4873f2c530752313dd3ebc2230dc2 Signed-off-by: Vishwanatha Subbanna <vishwa@linux.vnet.ibm.com>
-rw-r--r--obmc/dbuslib/bindings.py5
1 files changed, 5 insertions, 0 deletions
diff --git a/obmc/dbuslib/bindings.py b/obmc/dbuslib/bindings.py
index 203b56f..d3fdbaf 100644
--- a/obmc/dbuslib/bindings.py
+++ b/obmc/dbuslib/bindings.py
@@ -31,6 +31,7 @@ def get_dbus():
class DbusProperties(dbus.service.Object):
def __init__(self, **kw):
+ self.validator = kw.pop('validator')
super(DbusProperties, self).__init__(**kw)
self.properties = {}
self._export = False
@@ -76,6 +77,10 @@ class DbusProperties(dbus.service.Object):
def Set(self, interface_name, property_name, new_value):
if (interface_name not in self.properties):
self.properties[interface_name] = {}
+
+ if self.validator:
+ self.validator(interface_name, property_name, new_value)
+
try:
old_value = self.properties[interface_name][property_name]
if (old_value != new_value):
OpenPOWER on IntegriCloud