Exemple #1
0
def get_shadow_sort_order():
    """Return a topologically sorted list of shadow classes."""
    def _get_dependencies(shadow_class):
        return shadow_class.get_dependencies()

    shadow_classes = MetaShadow.shadowed_classes.values()
    graph = toposort.build_graph(shadow_classes, _get_dependencies)
    sorted_classes = toposort.topological_sort(graph)
    return sorted_classes
Exemple #2
0
def get_shadow_sort_order():
    """Return a topologically sorted list of shadow classes."""
    def _get_dependencies(shadow_class):
        return shadow_class.get_dependencies()

    shadow_classes = MetaShadow.shadowed_classes.values()
    graph = toposort.build_graph(shadow_classes, _get_dependencies)
    sorted_classes = toposort.topological_sort(graph)
    return sorted_classes
Exemple #3
0
 def get_managed(self):
     """
     Returns managed containers in topological sort order; the point being
     that containers can be inserted into the database in the returned
     order without raising integrity errors.
     """
     managed = super(EntityManager, self).get_managed()
     graph = build_graph(
         managed, lambda ent: [ent.contained_in]
         if ent.contained_in else [])
     return topological_sort(graph)