import sys

from javascript_configuration import settings

class ConfigurationBuilder:
    """
        Get javascript configurations from urls.py files from all installed apps.
    """
    def __init__(self):
        self.configuration = None

    def fetch(self):
        configuration = {}
        for app_name, module_name in settings.SCAN_MODULES.iter_items():
            try:
                __import__(module_name)
                urls = sys.modules[module_name]
                if hasattr(urls, 'javascript_configuration'):
                    configuration[app_name] = urls.javascript_configuration()
            except ImportError:
                pass
        return configuration

    def get_configuration(self):
        if self.configuration is None:
            self.configuration = self.fetch()
        return self.configuration

DEFAULT_CONFIGURATION_BUILDER = ConfigurationBuilder()

import sys

from javascript_configuration import settings

class ConfigurationBuilder:
    """
        Get javascript configurations from urls.py files from all installed apps.
    """
    def __init__(self):
        self.configuration = None

    def fetch(self):
        configuration = {}
        for app_name, module_name in settings.SCAN_MODULES.iteritems():
            try:
                __import__(module_name)
                urls = sys.modules[module_name]
                if hasattr(urls, 'javascript_configuration'):
                    configuration[app_name] = urls.javascript_configuration()
            except ImportError:
                pass
        return configuration

    def get_configuration(self):
        if self.configuration is None:
            self.configuration = self.fetch()
        return self.configuration

DEFAULT_CONFIGURATION_BUILDER = ConfigurationBuilder()

Fix bug in iteritems on SCAN_MODULES.
Fix bug in iteritems on SCAN_MODULES.

Change-Id: Ifa58f29a9e69ad46b44c301244525d711b43faca
Reviewed-on: http://review.pozytywnie.pl:8080/2340
Reviewed-by: Tomasz Wysocki <f17c2dc043305c950a029074ababd304e0373387@gmail.com>
Tested-by: Tomasz Wysocki <f17c2dc043305c950a029074ababd304e0373387@gmail.com>
