Beispiel #1
0
    def get_facets_for_collection(self, collection_id):
        """Return facets set for a collection.

        :param collection_id: the collection id for requested facets set
        """
        facets_conf = FacetCollection.query\
            .filter(FacetCollection.id_collection == collection_id)\
            .order_by(FacetCollection.order)\
            .all()

        collection_facets = []
        for facet in facets_conf:
            if facet.facet_name not in self.keys():
                raise RegistryError(
                    'Facet %s is not available.' +
                    'Maybe it\'s on PACKAGES_FACETS_EXCLUDE config list'
                    % facet.facet_name)
            collection_facets.append(self.get(facet.facet_name))

        return collection_facets
Beispiel #2
0
    def valuegetter(self, class_or_module):
        if inspect.ismodule(class_or_module):
            attr_name = class_or_module.__name__.split('.')[-1]
            if attr_name == '__init__':
                # Ignore __init__ modules.
                return None

            if hasattr(class_or_module, attr_name):
                #key = attr_name if key is None else key
                return getattr(class_or_module, attr_name)
            else:
                all_ = getattr(class_or_module, '__all__', [])
                if len(all_) == 0:
                    raise RegistryError(
                        "Workflow class not found. Class name must match "
                        "module name or be first element in  __all__. "
                        "Please check: {0}.{1}".format(class_or_module,
                                                       attr_name)
                    )
                return getattr(class_or_module, all_[0])
        return class_or_module
Beispiel #3
0
    def get_facets_for_collection(self, collection_id):
        """Return facets set for a collection.

        :param collection_id: the collection id for requested facets set
        """
        facets_conf = FacetCollection.query\
            .filter(FacetCollection.id_collection == collection_id)\
            .order_by(FacetCollection.order)\
            .all()

        collection_facets = []
        for facet in facets_conf:
            if facet.facet_name not in self.keys():
                raise RegistryError(
                    'Facet %s is not available. Please check if the facet '
                    'is located in package specified in PACKAGES_EXCLUDE or '
                    'in PACKAGES_FACETS_EXCLUDE configuration.'
                    % facet.facet_name)
            collection_facets.append(self.get(facet.facet_name))

        return collection_facets
Beispiel #4
0
 def _load_import_path(self, import_path):
     """Load module behind an import path."""
     m = super(MetricsRegistry, self)._load_import_path(import_path)
     if not issubclass(Metric, m):
         raise RegistryError("{0} is not a subclass of Metric.")
Beispiel #5
0
 def register(self, scope):
     """ Register an OAuth scope. """
     if not isinstance(scope, Scope):
         raise RegistryError("Invalid scope value.")
     super(ScopesRegistry, self).register(scope.id, scope)