Implement change registration
[cascardo/ipsilon.git] / ipsilon / info / common.py
index 16a7e29..4cd6663 100644 (file)
@@ -1,16 +1,15 @@
-# Copyright (C) 2014 Ipsilon Project Contributors
-#
-# See the file named COPYING for the project license
+# Copyright (C) 2014 Ipsilon project Contributors, for license see COPYING
 
 from ipsilon.util.log import Log
 from ipsilon.util.plugin import PluginInstaller, PluginLoader
-from ipsilon.util.plugin import PluginObject, PluginConfig
+from ipsilon.util.plugin import PluginObject
+from ipsilon.util.config import ConfigHelper
 
 
-class InfoProviderBase(PluginConfig, PluginObject):
+class InfoProviderBase(ConfigHelper, PluginObject):
 
     def __init__(self, *pargs):
-        PluginConfig.__init__(self)
+        ConfigHelper.__init__(self)
         PluginObject.__init__(self, *pargs)
 
     def get_user_attrs(self, user):
@@ -37,27 +36,12 @@ class InfoMapping(Log):
             'language': 'Language',
             'timezone': 'Time Zone',
         }
-        self.mapping = dict()
-
-    def set_mapping(self, attrs_map):
-        self.mapping = attrs_map
 
     def display_name(self, name):
         if name in self.standard_attributes:
             return self.standard_attributes[name]
         return name
 
-    def map_attrs(self, attrs):
-        s = dict()
-        e = dict()
-        for a in attrs:
-            if a in self.mapping:
-                s[self.mapping[a]] = attrs[a]
-            else:
-                e[a] = attrs[a]
-
-        return s, e
-
 
 FACILITY = 'info_config'
 
@@ -79,7 +63,13 @@ class Info(Log):
             if item not in plugins.available:
                 self.debug('Info Plugin %s not found' % item)
                 continue
-            plugins.available[item].enable()
+            try:
+                plugins.available[item].enable()
+            except Exception as e:  # pylint: disable=broad-except
+                while item in plugins.enabled:
+                    plugins.enabled.remove(item)
+                self.debug("Info Plugin %s couldn't be enabled: %s" % (
+                    item, str(e)))
 
     def get_user_attrs(self, user, requested=None):
         plugins = self._site[FACILITY].available
@@ -109,7 +99,13 @@ class InfoProviderInstaller(object):
     def install_args(self, group):
         raise NotImplementedError
 
-    def configure(self, opts):
+    def validate_args(self, args):
+        return
+
+    def unconfigure(self, opts, changes):
+        return
+
+    def configure(self, opts, changes):
         raise NotImplementedError