Пример #1
0
 def test_base_finder_check_not_implemented(self):
     finder = BaseFinder()
     msg = (
         "subclasses may provide a check() method to verify the finder is "
         "configured correctly."
     )
     with self.assertRaisesMessage(NotImplementedError, msg):
         finder.check()
Пример #2
0
    def __init__(self, app_name=None, *args, **kwargs):
        self.locations = []
        self.storages = OrderedDict()
        for site in Site.objects.all():
            current = get_domain_path(site.domain)
            root = os.path.join(settings.AIRAVATA_SITES_DIR, current, 'static')
            if os.path.exists(root) and (current, root) not in self.locations:
                self.locations.append((current, root))

        for prefix, root in self.locations:
            filesystem_storage = FileSystemStorage(location=root)
            filesystem_storage.prefix = prefix
            self.storages[root] = filesystem_storage
        BaseFinder.__init__(self, *args, **kwargs)
Пример #3
0
    def __init__(self, apps=None, *args, **kwargs):
        self.apps = []
        self.storages = SortedDict()
        visited = set()

        def traverse(path, root=False):
            for sub in os.listdir(path):
                full_path = os.path.abspath(os.path.join(path, sub))
                if full_path not in visited and os.path.isdir(full_path):
                    if sub == 'static' and not root:
                        storage = self.storage_class(full_path)
                        storage.prefix = None  # Иначе не работает
                        self.apps.append(full_path)
                        self.storages[full_path] = storage
                    else:
                        traverse(full_path)

        for app in settings.INSTALLED_APPS:
            mod = import_module(app)
            location = os.path.dirname(mod.__file__)
            traverse(location, root=True)

        # пропускаем __init__ предка, ибо не поведение переопределено
        BaseFinder.__init__(self, *args, **kwargs)
Пример #4
0
 def test_base_finder_check_not_implemented(self):
     finder = BaseFinder()
     msg = 'subclasses may provide a check() method to verify the finder is configured correctly.'
     with self.assertRaisesMessage(NotImplementedError, msg):
         finder.check()