Ejemplo n.º 1
0
class Tweens(object):
    def __init__(self):
        self.sorter = TopologicalSorter(default_before=None,
                                        default_after=INGRESS,
                                        first=INGRESS,
                                        last=MAIN)
        self.explicit = []

    def add_explicit(self, name, factory):
        self.explicit.append((name, factory))

    def add_implicit(self, name, factory, under=None, over=None):
        self.sorter.add(name, factory, after=under, before=over)

    def implicit(self):
        return self.sorter.sorted()

    def __call__(self, handler, registry):
        if self.explicit:
            use = self.explicit
        else:
            use = self.implicit()
        for name, factory in use[::-1]:
            handler = factory(handler, registry)
        return handler
Ejemplo n.º 2
0
class Tweens(object):
    def __init__(self):
        self.sorter = TopologicalSorter(
            default_before=None,
            default_after=INGRESS,
            first=INGRESS,
            last=MAIN)
        self.explicit = []

    def add_explicit(self, name, factory):
        self.explicit.append((name, factory))

    def add_implicit(self, name, factory, under=None, over=None):
        self.sorter.add(name, factory, after=under, before=over)

    def implicit(self):
        return self.sorter.sorted()

    def __call__(self, handler, registry):
        if self.explicit:
            use = self.explicit
        else:
            use = self.implicit()
        for name, factory in use[::-1]:
            handler = factory(handler, registry)
        return handler
Ejemplo n.º 3
0
 def __init__(self):
     self.sorter = TopologicalSorter(
         default_before=None,
         default_after=INGRESS,
         first=INGRESS,
         last=MAIN)
     self.explicit = []
Ejemplo n.º 4
0
 def _makeOne(self, *arg, **kw):
     from pyramid.config.util import TopologicalSorter
     return TopologicalSorter(*arg, **kw)