def __decorator(func): if not has_mark(func, 'filters'): set_mark(func, 'filters', []) # Since the add_filter will mostly be used as a decorator and because decorators # are applied in reverse order (the closest one to the function definition gets # applied first) we should apply the new filter to the beginning of the list so # the filter statements are easier to read. get_mark(func, 'filters').insert(0, filter) return func
def __decorate(func): if not has_mark(func, 'matchers'): set_mark(func, 'matchers', []) get_mark(func, 'matchers').append(matcher) return func