Ejemplo n.º 1
0
    def _get_application(self, version, app):
        settings = self.settings[version]
        settings_exclude = settings.get('exclude', {})

        if app in settings_exclude:
            raise NotRegistered("No such application label: %s" % app)

        settings_app = settings.get('apps', {}).get(app, {})
        ret = {}

        try:
            config = apps.get_app_config(app)
            ret = {
                'label': config.label,
                'verbose_name': config.verbose_name,
            }
        except LookupError:
            pass

        for n in settings_app:
            ret[n] = settings_app[n]
            ret['label'] = app
        if not ret:
            raise NotRegistered("No such application label: %s" % app)

        ret['models'] = self._get_application_models(version, app)

        return ret
Ejemplo n.º 2
0
    def canonical_resource_for(self, resource_name):
        """
        Returns the canonical resource for a given ``resource_name``.
        """
        if resource_name in self._canonicals:
            return self._canonicals[resource_name]

        raise NotRegistered("No resource was registered as canonical for '%s'." % resource_name)