Example #1
0
 def _load_config(self):
     dinj_config = None
     if hasattr(self, 'self._config') and self._config:
         return self._config
     else:
         try:
             try:
                 # first assume opts in OptionParser
                 if self._opts and self._opts.CONFIG:
                     dinj_config = DinjLexicon(parsable=self._opts.CONFIG)
             except:
                 # if not assume opts are a dict, collected from ConfigParser
                 if self._opts and 'pyaella_config' in self._opts:
                     dinj_config = \
                         DinjLexicon(parsable=self._opts['pyaella_config'])
         except:
             # lastly, look for config in environ
             print traceback.format_exc()
             if PSDC in os.environ:
                 dinj_config = DinjLexicon(
                     parsable=os.environ[PSDC])
         if dinj_config:
             # set for safe keeping
             #os.environ[PSDC] = dinj_config.__parsable
             try:
                 global APP_CONFIG
                 AppConfig = __borg_cls__('AppConfig')
                 if 'App' in dinj_config and 'AppId' in dinj_config.App:
                     app_kseq = get_app_kseq(
                         int(dinj_config.App.AppId), get_master_kseq())
                     d = dict(dinj_config.App.items())
                     d['AppKeySeq'] = app_kseq
                 d['FullConfigPath'] = os.path.abspath(self._opts.CONFIG)
                 APP_CONFIG = AppConfig(**d)                 
                 global MODEL_SCHEMA_CONFIG
                 MODEL_SCHEMA_CONFIG = __borg_lex__('ModelConfig')(
                             parsable=dinj_config.Resources.Schema)
             except:
                 print 'Ignoring exception', traceback.format_exc()
         else:
             raise Exception(
                 'Error during configuration injection. ' 
                 + 'Can not start cooking without the ingredients.'
             )
     return dinj_config
Example #2
0
def load_config():
    """Inject dependencies """

    global CONFIG
    dinj_config = DinjLexicon(parsable=OPTS.CONFIG)
    CONFIG = dinj_config
    
    global APP_CONFIG
    AppConfig = __borg_cls__('AppConfig')
    app_kseq = get_app_kseq(
        int(dinj_config.App.AppId), get_master_kseq())
    d = dict(dinj_config.App.items())
    d['AppKeySeq'] = app_kseq
    APP_CONFIG = AppConfig(**d)

    global MODEL_SCHEMA_CONFIG
    MODEL_SCHEMA_CONFIG = __borg_lex__('ModelConfig')(
                parsable=dinj_config.Resources.Schema)