Funktionierender Prototyp des Serious Games zur Vermittlung von Wissen zu Software-Engineering-Arbeitsmodellen.
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.

simple.py 2.4KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  1. """Simple base-classes for extensions and filters.
  2. None of the filter and extension functions are considered 'optional' by the
  3. framework. These base-classes provide simple implementations for the
  4. Initialize and Terminate functions, allowing you to omit them,
  5. It is not necessary to use these base-classes - but if you don't, you
  6. must ensure each of the required methods are implemented.
  7. """
  8. class SimpleExtension:
  9. "Base class for a simple ISAPI extension"
  10. def __init__(self):
  11. pass
  12. def GetExtensionVersion(self, vi):
  13. """Called by the ISAPI framework to get the extension version
  14. The default implementation uses the classes docstring to
  15. set the extension description."""
  16. # nod to our reload capability - vi is None when we are reloaded.
  17. if vi is not None:
  18. vi.ExtensionDesc = self.__doc__
  19. def HttpExtensionProc(self, control_block):
  20. """Called by the ISAPI framework for each extension request.
  21. sub-classes must provide an implementation for this method.
  22. """
  23. raise NotImplementedError("sub-classes should override HttpExtensionProc")
  24. def TerminateExtension(self, status):
  25. """Called by the ISAPI framework as the extension terminates."""
  26. pass
  27. class SimpleFilter:
  28. "Base class for a a simple ISAPI filter"
  29. filter_flags = None
  30. def __init__(self):
  31. pass
  32. def GetFilterVersion(self, fv):
  33. """Called by the ISAPI framework to get the extension version
  34. The default implementation uses the classes docstring to
  35. set the extension description, and uses the classes
  36. filter_flags attribute to set the ISAPI filter flags - you
  37. must specify filter_flags in your class.
  38. """
  39. if self.filter_flags is None:
  40. raise RuntimeError("You must specify the filter flags")
  41. # nod to our reload capability - fv is None when we are reloaded.
  42. if fv is not None:
  43. fv.Flags = self.filter_flags
  44. fv.FilterDesc = self.__doc__
  45. def HttpFilterProc(self, fc):
  46. """Called by the ISAPI framework for each filter request.
  47. sub-classes must provide an implementation for this method.
  48. """
  49. raise NotImplementedError("sub-classes should override HttpExtensionProc")
  50. def TerminateFilter(self, status):
  51. """Called by the ISAPI framework as the filter terminates."""
  52. pass