Use new Log class everywhere
authorSimo Sorce <simo@redhat.com>
Sat, 28 Jun 2014 00:26:22 +0000 (20:26 -0400)
committerPatrick Uiterwijk <puiterwijk@redhat.com>
Wed, 27 Aug 2014 22:15:03 +0000 (18:15 -0400)
Replace copies of _debug function sprinkled all over the code
with a single implementation

Signed-off-by: Simo Sorce <simo@redhat.com>
Reviewed-by: Patrick Uiterwijk <puiterwijk@redhat.com>
- Removed replace of self._debug to self.debug

ipsilon/login/common.py
ipsilon/providers/common.py
ipsilon/providers/saml2/provider.py
ipsilon/util/page.py
ipsilon/util/plugin.py
ipsilon/util/user.py

index a576345..acd6d94 100755 (executable)
@@ -17,6 +17,7 @@
 # You should have received a copy of the GNU General Public License
 # along with this program.  If not, see <http://www.gnu.org/licenses/>.
 
 # You should have received a copy of the GNU General Public License
 # along with this program.  If not, see <http://www.gnu.org/licenses/>.
 
+from ipsilon.util.log import Log
 from ipsilon.util.page import Page
 from ipsilon.util.user import UserSession
 from ipsilon.util.plugin import PluginLoader, PluginObject
 from ipsilon.util.page import Page
 from ipsilon.util.user import UserSession
 from ipsilon.util.plugin import PluginLoader, PluginObject
@@ -24,7 +25,7 @@ from ipsilon.util.plugin import PluginInstaller
 import cherrypy
 
 
 import cherrypy
 
 
-class LoginManagerBase(PluginObject):
+class LoginManagerBase(PluginObject, Log):
 
     def __init__(self):
         super(LoginManagerBase, self).__init__()
 
     def __init__(self):
         super(LoginManagerBase, self).__init__()
@@ -68,10 +69,6 @@ class LoginManagerBase(PluginObject):
 
         raise cherrypy.HTTPRedirect(ref)
 
 
         raise cherrypy.HTTPRedirect(ref)
 
-    def _debug(self, fact):
-        if cherrypy.config.get('debug', False):
-            cherrypy.log(fact)
-
     def get_tree(self, site):
         raise NotImplementedError
 
     def get_tree(self, site):
         raise NotImplementedError
 
index b1eab1a..94f747a 100755 (executable)
 # You should have received a copy of the GNU General Public License
 # along with this program.  If not, see <http://www.gnu.org/licenses/>.
 
 # You should have received a copy of the GNU General Public License
 # along with this program.  If not, see <http://www.gnu.org/licenses/>.
 
+from ipsilon.util.log import Log
 from ipsilon.util.plugin import PluginLoader, PluginObject
 from ipsilon.util.plugin import PluginInstaller
 from ipsilon.util.page import Page
 import cherrypy
 
 
 from ipsilon.util.plugin import PluginLoader, PluginObject
 from ipsilon.util.plugin import PluginInstaller
 from ipsilon.util.page import Page
 import cherrypy
 
 
-class ProviderException(Exception):
+class ProviderException(Exception, Log):
 
     def __init__(self, message):
         super(ProviderException, self).__init__(message)
 
     def __init__(self, message):
         super(ProviderException, self).__init__(message)
@@ -32,10 +33,6 @@ class ProviderException(Exception):
     def __str__(self):
         return repr(self.message)
 
     def __str__(self):
         return repr(self.message)
 
-    def _debug(self, fact):
-        if cherrypy.config.get('debug', False):
-            cherrypy.log('%s: %s' % (self.__class__.__name__, fact))
-
 
 class ProviderBase(PluginObject):
 
 
 class ProviderBase(PluginObject):
 
@@ -46,10 +43,6 @@ class ProviderBase(PluginObject):
         self.tree = None
         self.admin = None
 
         self.tree = None
         self.admin = None
 
-    def _debug(self, fact):
-        if cherrypy.config.get('debug', False):
-            cherrypy.log(fact)
-
     def get_tree(self, site):
         raise NotImplementedError
 
     def get_tree(self, site):
         raise NotImplementedError
 
@@ -136,7 +129,7 @@ class ProviderPageBase(Page):
 FACILITY = 'provider_config'
 
 
 FACILITY = 'provider_config'
 
 
-class LoadProviders(object):
+class LoadProviders(Log):
 
     def __init__(self, root, site):
         loader = PluginLoader(LoadProviders, FACILITY, 'IdpProvider')
 
     def __init__(self, root, site):
         loader = PluginLoader(LoadProviders, FACILITY, 'IdpProvider')
@@ -151,10 +144,6 @@ class LoadProviders(object):
             plugin = providers['available'][item]
             plugin.register(site)
 
             plugin = providers['available'][item]
             plugin.register(site)
 
-    def _debug(self, fact):
-        if cherrypy.config.get('debug', False):
-            cherrypy.log(fact)
-
 
 class ProvidersInstall(object):
 
 
 class ProvidersInstall(object):
 
index 8b7f04e..58ffbfe 100755 (executable)
@@ -19,7 +19,7 @@
 
 from ipsilon.providers.common import ProviderException
 from ipsilon.tools.saml2metadata import SAML2_NAMEID_MAP
 
 from ipsilon.providers.common import ProviderException
 from ipsilon.tools.saml2metadata import SAML2_NAMEID_MAP
-import cherrypy
+from ipsilon.util.log import Log
 import lasso
 
 
 import lasso
 
 
@@ -42,7 +42,7 @@ class NameIdNotAllowed(Exception):
         return repr(self.message)
 
 
         return repr(self.message)
 
 
-class ServiceProvider(object):
+class ServiceProvider(Log):
 
     def __init__(self, config, provider_id):
         self.cfg = config
 
     def __init__(self, config, provider_id):
         self.cfg = config
@@ -135,10 +135,6 @@ class ServiceProvider(object):
         idval = data.keys()[0]
         self.cfg.del_datum(idval)
 
         idval = data.keys()[0]
         self.cfg.del_datum(idval)
 
-    def _debug(self, fact):
-        if cherrypy.config.get('debug', False):
-            cherrypy.log(fact)
-
     def normalize_username(self, username):
         if 'strip domain' in self._properties:
             return username.split('@', 1)[0]
     def normalize_username(self, username):
         if 'strip domain' in self._properties:
             return username.split('@', 1)[0]
@@ -185,7 +181,7 @@ class ServiceProviderCreator(object):
         return ServiceProvider(self.cfg, spid)
 
 
         return ServiceProvider(self.cfg, spid)
 
 
-class IdentityProvider(object):
+class IdentityProvider(Log):
     def __init__(self, config):
         self.server = lasso.Server(config.idp_metadata_file,
                                    config.idp_key_file,
     def __init__(self, config):
         self.server = lasso.Server(config.idp_metadata_file,
                                    config.idp_key_file,
@@ -206,7 +202,3 @@ class IdentityProvider(object):
 
     def get_providers(self):
         return self.server.get_providers()
 
     def get_providers(self):
         return self.server.get_providers()
-
-    def _debug(self, fact):
-        if cherrypy.config.get('debug', False):
-            cherrypy.log(fact)
index aad91fc..10f10aa 100755 (executable)
@@ -17,6 +17,7 @@
 # You should have received a copy of the GNU General Public License
 # along with this program.  If not, see <http://www.gnu.org/licenses/>.
 
 # You should have received a copy of the GNU General Public License
 # along with this program.  If not, see <http://www.gnu.org/licenses/>.
 
+from ipsilon.util.log import Log
 from ipsilon.util.user import UserSession
 from urllib import unquote
 import cherrypy
 from ipsilon.util.user import UserSession
 from urllib import unquote
 import cherrypy
@@ -33,7 +34,7 @@ def admin_protect(fn):
     return check
 
 
     return check
 
 
-class Page(object):
+class Page(Log):
     def __init__(self, site, form=False):
         if 'template_env' not in site:
             raise ValueError('Missing template environment')
     def __init__(self, site, form=False):
         if 'template_env' not in site:
             raise ValueError('Missing template environment')
@@ -96,10 +97,6 @@ class Page(object):
         m.update(kwargs)
         return t.render(**m)
 
         m.update(kwargs)
         return t.render(**m)
 
-    def _debug(self, fact):
-        if cherrypy.config.get('debug', False):
-            cherrypy.log(fact)
-
     def default(self, *args, **kwargs):
         raise cherrypy.HTTPError(404)
 
     def default(self, *args, **kwargs):
         raise cherrypy.HTTPError(404)
 
index 730ce6c..edfda16 100755 (executable)
@@ -22,6 +22,7 @@ import imp
 import cherrypy
 import inspect
 from ipsilon.util.data import Store
 import cherrypy
 import inspect
 from ipsilon.util.data import Store
+from ipsilon.util.log import Log
 
 
 class Plugins(object):
 
 
 class Plugins(object):
@@ -102,7 +103,7 @@ class PluginInstaller(object):
         return p.get_plugins(self._pathname, 'Installer')
 
 
         return p.get_plugins(self._pathname, 'Installer')
 
 
-class PluginObject(object):
+class PluginObject(Log):
 
     def __init__(self):
         self.name = None
 
     def __init__(self):
         self.name = None
index 7c53526..84f1818 100755 (executable)
@@ -18,6 +18,7 @@
 # along with this program.  If not, see <http://www.gnu.org/licenses/>.
 
 from ipsilon.util.data import Store
 # along with this program.  If not, see <http://www.gnu.org/licenses/>.
 
 from ipsilon.util.data import Store
+from ipsilon.util.log import Log
 import cherrypy
 
 
 import cherrypy
 
 
@@ -98,14 +99,10 @@ class User(object):
         raise AttributeError
 
 
         raise AttributeError
 
 
-class UserSession(object):
+class UserSession(Log):
     def __init__(self):
         self.user = self.get_data('user', 'name')
 
     def __init__(self):
         self.user = self.get_data('user', 'name')
 
-    def _debug(self, fact):
-        if cherrypy.config.get('debug', False):
-            cherrypy.log(fact)
-
     def get_user(self):
         return User(self.user)
 
     def get_user(self):
         return User(self.user)