codekingpro/portable-devtools
114k
1"""Simple base-classes for extensions and filters.2 3None of the filter and extension functions are considered 'optional' by the4framework. These base-classes provide simple implementations for the5Initialize and Terminate functions, allowing you to omit them,6 7It is not necessary to use these base-classes - but if you don't, you8must ensure each of the required methods are implemented.9"""10 11 12class SimpleExtension:13 "Base class for a simple ISAPI extension"14 15 def __init__(self):16 pass17 18 def GetExtensionVersion(self, vi):19 """Called by the ISAPI framework to get the extension version20 21 The default implementation uses the classes docstring to22 set the extension description."""23 # nod to our reload capability - vi is None when we are reloaded.24 if vi is not None:25 vi.ExtensionDesc = self.__doc__26 27 def HttpExtensionProc(self, control_block):28 """Called by the ISAPI framework for each extension request.29 30 sub-classes must provide an implementation for this method.31 """32 raise NotImplementedError("sub-classes should override HttpExtensionProc")33 34 def TerminateExtension(self, status):35 """Called by the ISAPI framework as the extension terminates."""36 pass37 38 39class SimpleFilter:40 "Base class for a a simple ISAPI filter"41 filter_flags = None42 43 def __init__(self):44 pass45 46 def GetFilterVersion(self, fv):47 """Called by the ISAPI framework to get the extension version48 49 The default implementation uses the classes docstring to50 set the extension description, and uses the classes51 filter_flags attribute to set the ISAPI filter flags - you52 must specify filter_flags in your class.53 """54 if self.filter_flags is None:55 raise RuntimeError("You must specify the filter flags")56 # nod to our reload capability - fv is None when we are reloaded.57 if fv is not None:58 fv.Flags = self.filter_flags59 fv.FilterDesc = self.__doc__60 61 def HttpFilterProc(self, fc):62 """Called by the ISAPI framework for each filter request.63 64 sub-classes must provide an implementation for this method.65 """66 raise NotImplementedError("sub-classes should override HttpExtensionProc")67 68 def TerminateFilter(self, status):69 """Called by the ISAPI framework as the filter terminates."""70 pass71 