Commits

James Mills  committed 1e9983d

circuits.app: Fixed a bug with loading a Logger instance and loading the Config instance (circuits.app needs to be refactored)

  • Participants
  • Parent commits 01fc269

Comments (0)

Files changed (2)

File circuits/app/config.py

 ### Events
 ###
 
-class Load(Event):
-    """Load(Event) -> Load Event"""
+class LoadConfig(Event):
+    """Load Config Event"""
 
-class Save(Event):
-    """Save(Event) -> Save Event"""
+    end = "config_loaded",
+
+class SaveConfig(Event):
+    """Save Config Event"""
 
 ###
 ### Components

File circuits/app/env.py

 from circuits import handler, Event, Component
 
 from log import Logger
-from config import (
-        Config,
-        Load as LoadConfig,
-        Save as SaveConfig)
+from config import Config, LoadConfig, SaveConfig
 
 ###
 ### Constants
         self.manager += self.config
         self.push(LoadConfig(), "load", "config")
 
+    @handler("config_loaded", target="config")
+    def _on_config_loaded(self, evt, handler, retval):
         # Create Logger Component
         logname = self.envname
         logtype = self.config.get("logging", "type", "file")
         logfile = logfile % {"name": self.envname}
         if not os.path.isabs(logfile):
             logfile = os.path.join(self.path, logfile)
-        self.log = Logger(logfile, logname, logtype, loglevel)
-        self.manager += self.log
+        self.log = Logger(logfile, logname, logtype,
+                loglevel).register(self)
+        print "Creating logger..."
 
         self.push(Loaded(), "loaded", self.channel)