summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRob Crittenden <rcritten@redhat.com>2015-04-08 09:44:14 -0400
committerSimo Sorce <simo@redhat.com>2015-04-10 10:38:15 -0400
commit434bffc3b1ab4a74f0f23508e624e7427987aaf8 (patch)
treede5dcf9470706563e4fc348eeac654e38e47cc9a
parente235c7be58ddf563ed6fd6d6f52dbc96497b0389 (diff)
downloadipsilon-434bffc3b1ab4a74f0f23508e624e7427987aaf8.zip
ipsilon-434bffc3b1ab4a74f0f23508e624e7427987aaf8.tar.gz
ipsilon-434bffc3b1ab4a74f0f23508e624e7427987aaf8.tar.xz
Rename and move PluginConfig to ConfigHelper
The configuration class was originally intended to be tied. At this point it is quite generic and useful outside of plugins. Rename it to something more generic and move it into the config module. https://fedorahosted.org/ipsilon/ticket/25 Signed-off-by: Rob Crittenden <rcritten@redhat.com> Reviewed-by: Simo Sorce <simo@redhat.com>
-rw-r--r--ipsilon/admin/common.py2
-rw-r--r--ipsilon/info/common.py7
-rw-r--r--ipsilon/login/common.py7
-rw-r--r--ipsilon/providers/common.py7
-rw-r--r--ipsilon/providers/saml2/provider.py4
-rw-r--r--ipsilon/util/config.py38
-rw-r--r--ipsilon/util/plugin.py39
7 files changed, 53 insertions, 51 deletions
diff --git a/ipsilon/admin/common.py b/ipsilon/admin/common.py
index ceccdc9..7484806 100644
--- a/ipsilon/admin/common.py
+++ b/ipsilon/admin/common.py
@@ -54,7 +54,7 @@ class AdminPluginConfig(AdminPage):
self.back = parent.url
def root_with_msg(self, message=None, message_type=None):
- return self._template('admin/plugin_config.html', title=self.title,
+ return self._template('admin/option_config.html', title=self.title,
menu=self.menu, action=self.url, back=self.back,
message=message, message_type=message_type,
name='admin_%s_%s_form' % (self.facility,
diff --git a/ipsilon/info/common.py b/ipsilon/info/common.py
index dd48ae9..a97d648 100644
--- a/ipsilon/info/common.py
+++ b/ipsilon/info/common.py
@@ -4,13 +4,14 @@
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):
diff --git a/ipsilon/login/common.py b/ipsilon/login/common.py
index d616882..9496a4b 100644
--- a/ipsilon/login/common.py
+++ b/ipsilon/login/common.py
@@ -18,7 +18,8 @@
from ipsilon.util.page import Page
from ipsilon.util.user import UserSession
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
from ipsilon.info.common import Info
from ipsilon.util.cookies import SecureCookie
import cherrypy
@@ -27,10 +28,10 @@ import cherrypy
USERNAME_COOKIE = 'ipsilon_default_username'
-class LoginManagerBase(PluginConfig, PluginObject):
+class LoginManagerBase(ConfigHelper, PluginObject):
def __init__(self, *args):
- PluginConfig.__init__(self)
+ ConfigHelper.__init__(self)
PluginObject.__init__(self, *args)
self._root = None
self._site = None
diff --git a/ipsilon/providers/common.py b/ipsilon/providers/common.py
index 74c00df..a0158d9 100644
--- a/ipsilon/providers/common.py
+++ b/ipsilon/providers/common.py
@@ -17,7 +17,8 @@
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
from ipsilon.util.page import Page
from ipsilon.util.page import admin_protect
from ipsilon.rest.common import RestPage
@@ -49,10 +50,10 @@ class InvalidRequest(ProviderException):
self._debug(message)
-class ProviderBase(PluginConfig, PluginObject):
+class ProviderBase(ConfigHelper, PluginObject):
def __init__(self, name, path, *pargs):
- PluginConfig.__init__(self)
+ ConfigHelper.__init__(self)
PluginObject.__init__(self, *pargs)
self.name = name
self._root = None
diff --git a/ipsilon/providers/saml2/provider.py b/ipsilon/providers/saml2/provider.py
index 1143c9f..d3cc144 100644
--- a/ipsilon/providers/saml2/provider.py
+++ b/ipsilon/providers/saml2/provider.py
@@ -17,7 +17,7 @@
from ipsilon.providers.common import ProviderException
from ipsilon.util import config as pconfig
-from ipsilon.util.plugin import PluginConfig
+from ipsilon.util.config import ConfigHelper
from ipsilon.tools.saml2metadata import SAML2_NAMEID_MAP
from ipsilon.util.log import Log
import lasso
@@ -46,7 +46,7 @@ class NameIdNotAllowed(Exception):
return repr(self.message)
-class ServiceProviderConfig(PluginConfig):
+class ServiceProviderConfig(ConfigHelper):
def __init__(self):
super(ServiceProviderConfig, self).__init__()
diff --git a/ipsilon/util/config.py b/ipsilon/util/config.py
index 947c697..523601d 100644
--- a/ipsilon/util/config.py
+++ b/ipsilon/util/config.py
@@ -322,3 +322,41 @@ class Condition(Pick):
def import_value(self, value):
self._assigned_value = value == 'True'
+
+
+class ConfigHelper(Log):
+
+ def __init__(self):
+ self._config = None
+
+ def new_config(self, name, *config_args):
+ self._config = Config(name, *config_args)
+
+ def get_config_obj(self):
+ if self._config is None:
+ raise AttributeError('Config not initialized')
+ return self._config
+
+ def import_config(self, config):
+ if not self._config:
+ raise AttributeError('Config not initialized, cannot import')
+
+ for key, value in config.iteritems():
+ if key in self._config:
+ self._config[key].import_value(str(value))
+
+ def export_config(self):
+ config = dict()
+ for name, option in self._config.iteritems():
+ config[name] = option.export_value()
+ return config
+
+ def get_config_value(self, name):
+ if not self._config:
+ raise AttributeError('Config not initialized')
+ return self._config[name].get_value()
+
+ def set_config_value(self, name, value):
+ if not self._config:
+ raise AttributeError('Config not initialized')
+ return self._config[name].set_value(value)
diff --git a/ipsilon/util/plugin.py b/ipsilon/util/plugin.py
index 1035ca8..be6dd2f 100644
--- a/ipsilon/util/plugin.py
+++ b/ipsilon/util/plugin.py
@@ -19,7 +19,6 @@ import os
import imp
import cherrypy
import inspect
-from ipsilon.util.config import Config
from ipsilon.util.data import AdminStore
from ipsilon.util.log import Log
@@ -213,41 +212,3 @@ class PluginObject(Log):
def wipe_data(self):
self._data.wipe_data(self.name)
-
-
-class PluginConfig(Log):
-
- def __init__(self):
- self._config = None
-
- def new_config(self, name, *config_args):
- self._config = Config(name, *config_args)
-
- def get_config_obj(self):
- if self._config is None:
- raise AttributeError('Config not initialized')
- return self._config
-
- def import_config(self, config):
- if not self._config:
- raise AttributeError('Config not initialized, cannot import')
-
- for key, value in config.iteritems():
- if key in self._config:
- self._config[key].import_value(str(value))
-
- def export_config(self):
- config = dict()
- for name, option in self._config.iteritems():
- config[name] = option.export_value()
- return config
-
- def get_config_value(self, name):
- if not self._config:
- raise AttributeError('Config not initialized')
- return self._config[name].get_value()
-
- def set_config_value(self, name, value):
- if not self._config:
- raise AttributeError('Config not initialized')
- return self._config[name].set_value(value)