Browse Source

Modified singleton sessionHandler: from __new__ to __init__ checked

m.orban 8 years ago
parent
commit
9ae7855c50
2 changed files with 6 additions and 7 deletions
  1. 5
    6
      lodel/plugin/plugins.py
  2. 1
    1
      lodel/settings/validator.py

+ 5
- 6
lodel/plugin/plugins.py View File

795
 
795
 
796
 class SessionHandler(Plugin):
796
 class SessionHandler(Plugin):
797
     __instance = None
797
     __instance = None
798
-
799
-    def __new__(cls):
800
-        if cls.__instance == None:
801
-            cls.instance == object.__new__(cls)
802
-        return cls.__instance
803
         
798
         
804
     def __init__(self, plugin_name):
799
     def __init__(self, plugin_name):
805
-        super(Plugin, self).__init__(plugin_name)
800
+        if self.__instance is None:
801
+            super(Plugin, self).__init__(plugin_name)
802
+            self.__instance = True
803
+        else:
804
+            raise RuntimeError("A SessionHandler Plugin is already plug")
806
 
805
 
807
 class InterfacePlugin(Plugin):
806
 class InterfacePlugin(Plugin):
808
     def __init__(self, plugin_name):
807
     def __init__(self, plugin_name):

+ 1
- 1
lodel/settings/validator.py View File

240
     return value
240
     return value
241
 
241
 
242
 def plugin_val(value):
242
 def plugin_val(value):
243
-    if spl = value.split('.')
243
+    spl = value.split('.')
244
     if len(spl) != 2:
244
     if len(spl) != 2:
245
         msg = "Expected a value in the form PLUGIN.TYPE but got : %s"
245
         msg = "Expected a value in the form PLUGIN.TYPE but got : %s"
246
         raise SettingsValidationError(msg % value)
246
         raise SettingsValidationError(msg % value)

Loading…
Cancel
Save