def _register_context_handler(parents, func): name = func.__name__ parents = list(itertools.takewhile(lambda x: name in x.registry, parents)) if not parents: return ctx_handlers = parents[-1].context_handlers for c in _get_ctx_dependencies(func): for old in ctx_handlers[name][c]: dr.add_ignore(old, c) ctx_handlers[name][c].append(func)
def _register_context_handler(parents, component): name = component.__name__ parents = list(itertools.takewhile(lambda x: name in x.registry, parents)) if not parents: return # If the new component handles a context, we need to tell the # previously registered components that would have handled it to ignore it. # The components that handle a context are registered on the highest class # of the MRO list. This is so overrides work correctly even if a # component isn't a direct sibling of the component it's overriding. # instead of trying to unhook all of the dependencies, we just tell the # previous handler of a context to ignore it. ctx_handlers = parents[-1].context_handlers for c in _get_ctx_dependencies(component): for old in ctx_handlers[name][c]: dr.add_ignore(old, c) ctx_handlers[name][c].append(component)