Global Registry


        NOTE: Parses main conf files (/etc/fwissr/fwissr.json
            and ~/.fwissr/fwissr.json)

        then uses 'fwissr_sources' setting to setup additional sources

        Example of /etc/fwissr/fwissr.json file:

         {
           'fwissr_sources': [
             { 'filepath': '/mnt/my_app/conf/' },
             { 'filepath': '/etc/my_app.json' },
             { 'mongodb': 'mongodb://db1.example.net/my_app',
                 'collection': 'config', 'refresh': true },
           ],
           'fwissr_refresh_period': 30,
        }
        access global registry with Fwissr['/foo/bar']

def global_registry(self):
        """Global Registry


        NOTE: Parses main conf files (/etc/fwissr/fwissr.json
            and ~/.fwissr/fwissr.json)

        then uses 'fwissr_sources' setting to setup additional sources

        Example of /etc/fwissr/fwissr.json file:

         {
           'fwissr_sources': [
             { 'filepath': '/mnt/my_app/conf/' },
             { 'filepath': '/etc/my_app.json' },
             { 'mongodb': 'mongodb://db1.example.net/my_app',
                 'collection': 'config', 'refresh': true },
           ],
           'fwissr_refresh_period': 30,
        }
        access global registry with Fwissr['/foo/bar']
        """
        if self._global_registry is None:
            if 'fwissr_refresh_period' in self.main_conf:
                result = Registry(
                    refresh_period=self.main_conf['fwissr_refresh_period'])
            else:
                result = Registry()

            if (os.path.exists(self.main_conf_path) or
                    os.path.exists(self.main_user_conf_path)):

                if os.path.exists(self.main_conf_path):
                    result.add_source(
                        Source.from_settings(
                            {'filepath': self.main_conf_path}))

                if os.path.exists(self.main_user_conf_path):
                    result.add_source(
                        Source.from_settings(
                            {'filepath': self.main_user_conf_path}))

                if 'fwissr_sources' in self.main_conf:
                    for source in self.main_conf['fwissr_sources']:
                        result.add_source(Source.from_settings(source))

            self._global_registry = result
        return self._global_registry