Guest User

Untitled

a guest
Jun 21st, 2018
85
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.76 KB | None | 0 0
  1. """Default page handler.
  2. """
  3. from PyISAPIe import Env
  4. from hashlib import md5
  5. import imp
  6.  
  7. from Error import HandleNotFound
  8.  
  9. Handlers = {}
  10.  
  11.  
  12. def Request(Path):
  13. Script = Env.SCRIPT_NAME
  14. Key = Name = '__'+md5(Script).hexdigest().upper()
  15. Handler = Handlers.get(Key, None)
  16.  
  17. if not Handler:
  18. try:
  19. Handlers[Key] = imp.load_source(Key, Env.SCRIPT_TRANSLATED).Request
  20. except Exception, Val:
  21. # trigger a passthrough to the next ISAPI handler -
  22. # ONLY WORKS FOR WILDCARD APPLICATION MAPPINGS
  23. #return True
  24. # or just fail, preferable for an application map
  25. if type(Val).__name__ == "IOError":
  26. HandleNotFound(Path)
  27. else:
  28. raise ImportError, "[Loading '%s'] %s" % (Env.SCRIPT_TRANSLATED, str(Val))
  29.  
  30.  
  31. return Handlers[Key]()
Add Comment
Please, Sign In to add comment