def includableInfo(self, zcml_to_look_for):
        """Return the packages in the dependencies which are includable.

        zcml_to_look_for - a list of zcml filenames we are looking for

        Returns a dictionary with the include candidates as keys, and lists
        of dotted names of packages that contain the include candidates as
        values.
        """
        result = ZCMLInfo(zcml_to_look_for)
        for req in self.context.requires():
            dist_manager = DistributionManager(get_provider(req))
            for dotted_name in dist_manager.dottedNames():
                try:
                    module = resolve(dotted_name)
                except ImportError as exc:
                    logging.getLogger("z3c.autoinclude").warn(
                        "resolve(%r) raised import error: %s" % (dotted_name, exc))
                    continue
                for candidate in zcml_to_look_for:
                    candidate_path = os.path.join(
                        os.path.dirname(module.__file__), candidate)
                    if os.path.isfile(candidate_path):
                        result[candidate].append(dotted_name)
        return result
def getDependencyInfosForDeferred():
    """
    Return dictionary with lists of configuration files
    for the dependencies of the deferred eggs.
    """
    deferred = ['zc.table', 'hurry.workflow']
    # XXX: Assuming that all dependencies should be autoincluded
    # will probably get us into trouble, but let's see how big trouble.
    # *zc.table* is an example of a dependency, whose *configure.zcml*
    # will not run in Plone environment.
    # Some better solution than just a blacklist would be welcome.
    from sauna.reload import reload_paths
    zcml_to_look_for = ('meta.zcml', 'configure.zcml', 'overrides.zcml')
    deps = ZCMLInfo(zcml_to_look_for)
    for ep in iter_entry_points('z3c.autoinclude.plugin'):
        if ep.module_name == DEFERRED_TARGET:
            deferred.append(ep.dist.project_name)
            # XXX: We cannot call DependencyFinder(ep.dist).includableInfo,
            # because it eventually imports also our development packages
            # while resolving existence of *zcml_to_look_for*.
            finder = DependencyFinder(ep.dist)
            info = ZCMLInfo(zcml_to_look_for)
            for req in finder.context.requires():
                # Skip missing and deferred requirements
                dist = ws.find(req)  # find req from the current working set
                if dist is None or dist.location in reload_paths:
                    continue
                # Resolve ZCMLs to be loaded for the other requirements
                dist_manager = DistributionManager(get_provider(req))
                for dotted_name in dist_manager.dottedNames():
                    try:
                        module = resolve(dotted_name)
                    except ImportError:
                        continue
                    for candidate in zcml_to_look_for:
                        try:
                            candidate_path = os.path.join(
                                os.path.dirname(module.__file__), candidate)
                        except AttributeError:
                            continue
                        if os.path.isfile(candidate_path):
                            info[candidate].append(dotted_name)
            for key in deps:
                deps[key].extend(info.get(key, []))
    for key in deps:
        deps[key] = set([n for n in deps[key] if n not in deferred])
    return deps
Exemple #3
0
    def includableInfo(self, zcml_to_look_for):
        includable_info = ZCMLInfo(zcml_to_look_for)

        for plugin_distribution in find_plugins(self.dottedname):
            include_finder = DistributionManager(plugin_distribution)
            for plugin_dottedname in include_finder.dottedNames():
                groups = zcml_to_include(plugin_dottedname, zcml_to_look_for)
                for zcml_group in groups:
                    includable_info[zcml_group].append(plugin_dottedname)
        return includable_info
Exemple #4
0
def getDependencyInfosForDeferred():
    """
    Return dictionary with lists of configuration files
    for the dependencies of the deferred eggs.
    """
    deferred = ['zc.table', 'hurry.workflow']
    # XXX: Assuming that all dependencies should be autoincluded
    # will probably get us into trouble, but let's see how big trouble.
    # *zc.table* is an example of a dependency, whose *configure.zcml*
    # will not run in Plone environment.
    # Some better solution than just a blacklist would be welcome.
    from sauna.reload import reload_paths
    zcml_to_look_for = ('meta.zcml', 'configure.zcml', 'overrides.zcml')
    deps = ZCMLInfo(zcml_to_look_for)
    for ep in iter_entry_points('z3c.autoinclude.plugin'):
        if ep.module_name == DEFERRED_TARGET:
            deferred.append(ep.dist.project_name)
            # XXX: We cannot call DependencyFinder(ep.dist).includableInfo,
            # because it eventually imports also our development packages
            # while resolving existence of *zcml_to_look_for*.
            finder = DependencyFinder(ep.dist)
            info = ZCMLInfo(zcml_to_look_for)
            for req in finder.context.requires():
                # Skip missing and deferred requirements
                dist = ws.find(req)  # find req from the current working set
                if dist is None or dist.location in reload_paths:
                    continue
                # Resolve ZCMLs to be loaded for the other requirements
                dist_manager = DistributionManager(get_provider(req))
                for dotted_name in dist_manager.dottedNames():
                    module = resolve(dotted_name)
                    for candidate in zcml_to_look_for:
                        candidate_path = os.path.join(
                            os.path.dirname(module.__file__), candidate)
                        if os.path.isfile(candidate_path):
                            info[candidate].append(dotted_name)
            for key in deps:
                deps[key].extend(info.get(key, []))
    for key in deps:
        deps[key] = set([n for n in deps[key] if n not in deferred])
    return deps
def get_deferred_deps_info():
    """Return dictionary with lists of configuration files for the dependencies
    of the deferred eggs"""
    deferred = ["zc.table"]
    # FIXME: Assuming that all dependencies should be autoincluded will
    # probably get us into trouble, but let's see how big trouble. ``zc.table``
    # is an example of a dependency, whose ``configure.zcml`` will not run in
    # Plone environment. Some better solution than just a blacklist would be
    # welcome.
    from sauna.reload import reload_paths
    zcml_to_look_for = ("meta.zcml", "configure.zcml", "overrides.zcml")
    deps = ZCMLInfo(zcml_to_look_for)
    for ep in iter_entry_points("z3c.autoinclude.plugin"):
        if ep.module_name == DEFERRED_TARGET:
            deferred.append(ep.dist.project_name)
            # XXX: We cannot call DependencyFinder(ep.dist).includableInfo,
            # because it eventually imports also our development packages while
            # resolving existence of ``zcml_to_look_for``.
            finder = DependencyFinder(ep.dist)
            info = ZCMLInfo(zcml_to_look_for)
            for req in finder.context.requires():
                # Skip missing and deferred requirements
                dist = ws.find(req)  # find req from the current working set
                if dist is None or dist.location in reload_paths:
                    continue
                # Resolve ZCMLs to be loaded for the other requirements
                dist_manager = DistributionManager(get_provider(req))
                for dotted_name in dist_manager.dottedNames():
                    module = resolve(dotted_name)
                    for candidate in zcml_to_look_for:
                        candidate_path = os.path.join(
                            os.path.dirname(module.__file__), candidate)
                        if os.path.isfile(candidate_path):
                            info[candidate].append(dotted_name)
            for key in deps:
                deps[key].extend(info.get(key, []))
    for key in deps:
        deps[key] = set([n for n in deps[key] if n not in deferred])
    return deps