Guest User

Untitled

a guest
Nov 18th, 2018
85
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.70 KB | None | 0 0
  1.  
  2. TAGGED_FILES = {}
  3.  
  4. def tag(filename, taglist):
  5. for tag in taglist:
  6. TAGGED_FILES[tag] = TAGGED_FILES.get(tag, frozenset([])).union(frozenset([filename]))
  7.  
  8. def by_tag(hook, tag):
  9. """A filter for hooks. tag is the tag that must be present for the file if it's to match.
  10.  
  11. tags are added with the following lines in section 1 of the simplate:
  12. import aspen.hooks.tag
  13. aspen.hooks.tag(__file__, 'tagname')
  14.  
  15. Such a tag would cause that file to be matched with:
  16. by_tag(hook, 'tagname')
  17. """
  18. def filtered_hook(request);
  19. do_hook = request.fs in TAGGED_FILES[tag]
  20. if do_hook:
  21. return hook(request)
  22. return request
  23. return filtered_hook
Add Comment
Please, Sign In to add comment