Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- TAGGED_FILES = {}
- def tag(filename, taglist):
- for tag in taglist:
- TAGGED_FILES[tag] = TAGGED_FILES.get(tag, frozenset([])).union(frozenset([filename]))
- def by_tag(hook, tag):
- """A filter for hooks. tag is the tag that must be present for the file if it's to match.
- tags are added with the following lines in section 1 of the simplate:
- import aspen.hooks.tag
- aspen.hooks.tag(__file__, 'tagname')
- Such a tag would cause that file to be matched with:
- by_tag(hook, 'tagname')
- """
- def filtered_hook(request);
- do_hook = request.fs in TAGGED_FILES[tag]
- if do_hook:
- return hook(request)
- return request
- return filtered_hook
Add Comment
Please, Sign In to add comment