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
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
def __init__(self): self.sorter = TopologicalSorter( default_before=None, default_after=INGRESS, first=INGRESS, last=MAIN) self.explicit = []
def _makeOne(self, *arg, **kw): from pyramid.config.util import TopologicalSorter return TopologicalSorter(*arg, **kw)