A copyright violation detector running on Wikimedia Cloud Services https://tools.wmflabs.org/copyvios/
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

settings.py 1.0 KiB

12 年之前
1234567891011121314151617181920212223242526272829
  1. # -*- coding: utf-8 -*-
  2. from .cookies import parse_cookies, set_cookie, delete_cookie
  3. from .misc import get_bot, Query
  4. from .sites import get_sites
  5. def main(context, environ, headers):
  6. cookies = parse_cookies(context, environ)
  7. query = Query(environ, method="POST")
  8. if query.action == "set":
  9. if query.lang:
  10. key = "EarwigDefaultLang"
  11. if key not in cookies or cookies[key].value != query.lang:
  12. set_cookie(headers, cookies, key, query.lang, 365)
  13. if query.project:
  14. key = "EarwigDefaultProject"
  15. if key not in cookies or cookies[key].value != query.project:
  16. set_cookie(headers, cookies, key, query.project, 365)
  17. elif query.action == "delete":
  18. if query.cookie in cookies:
  19. delete_cookie(headers, cookies, query.cookie)
  20. elif query.all:
  21. for cookie in cookies.values():
  22. delete_cookie(headers, cookies, cookie.key)
  23. bot = get_bot()
  24. langs, projects = get_sites(bot)
  25. return bot, cookies, langs, projects