X-Git-Url: http://git.cascardo.info/?p=cascardo%2Fipsilon.git;a=blobdiff_plain;f=ipsilon%2Flogin%2Fcommon.py;h=028b7544838be1f2c3622d2ffc83335bf8206669;hp=6cd1ca83cfdb842dd33400ce0b011dfbc9c01682;hb=62b4656571be6e8671ada295047eac385d330f66;hpb=d597f362db9012a47164369e7614fd6a2060e7e5 diff --git a/ipsilon/login/common.py b/ipsilon/login/common.py index 6cd1ca8..028b754 100755 --- a/ipsilon/login/common.py +++ b/ipsilon/login/common.py @@ -17,7 +17,6 @@ # You should have received a copy of the GNU General Public License # along with this program. If not, see . -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 @@ -30,13 +29,15 @@ import cherrypy USERNAME_COOKIE = 'ipsilon_default_username' -class LoginManagerBase(PluginObject, Log): +class LoginManagerBase(PluginObject): def __init__(self): super(LoginManagerBase, self).__init__() + self._site = None self.path = '/' self.next_login = None self.info = None + self.is_enabled = False def redirect_to_path(self, path): base = cherrypy.config.get('base.mount', "") @@ -116,10 +117,13 @@ class LoginManagerBase(PluginObject, Log): raise NotImplementedError def enable(self, site): - plugins = site[FACILITY] - if self in plugins['enabled']: + if self.is_enabled: return + if not self._site: + self._site = site + plugins = self._site[FACILITY] + # configure self if self.name in plugins['config']: self.set_config(plugins['config'][self.name]) @@ -141,16 +145,18 @@ class LoginManagerBase(PluginObject, Log): root.first_login = self plugins['enabled'].append(self) + self.is_enabled = True self._debug('Login plugin enabled: %s' % self.name) # Get handle of the info plugin self.info = root.info def disable(self, site): - plugins = site[FACILITY] - if self not in plugins['enabled']: + if not self.is_enabled: return + plugins = self._site[FACILITY] + # remove self from chain root = plugins['root'] if root.first_login == self: @@ -164,6 +170,7 @@ class LoginManagerBase(PluginObject, Log): self.next_login = None plugins['enabled'].remove(self) + self.is_enabled = False self._debug('Login plugin disabled: %s' % self.name)