home *** CD-ROM | disk | FTP | other *** search
/ Maximum CD 2010 November / maximum-cd-2010-11.iso / DiscContents / calibre-0.7.13.msi / file_1984 (.txt) < prev    next >
Encoding:
Python Compiled Bytecode  |  2010-08-06  |  3.6 KB  |  92 lines

  1. # Source Generated with Decompyle++
  2. # File: in.pyc (Python 2.6)
  3.  
  4. from isapi import isapicon, threaded_extension, ExtensionError
  5. from isapi.simple import SimpleFilter
  6. import traceback
  7. import urllib
  8. import winerror
  9. import win32api
  10.  
  11. try:
  12.     win32api.GetConsoleTitle()
  13. except win32api.error:
  14.     import win32traceutil
  15.  
  16.  
  17. class Extension(threaded_extension.ThreadPoolExtension):
  18.     
  19.     def Dispatch(self, ecb):
  20.         print 'Tester dispatching "%s"' % (ecb.GetServerVariable('URL'),)
  21.         url = ecb.GetServerVariable('URL')
  22.         test_name = url.split('/')[-1]
  23.         meth = getattr(self, test_name, None)
  24.         if meth is None:
  25.             raise AttributeError, "No test named '%s'" % (test_name,)
  26.         meth is None
  27.         result = meth(ecb)
  28.         if result is None:
  29.             return None
  30.         ecb.SendResponseHeaders('200 OK', 'Content-type: text/html\r\n\r\n', False)
  31.         print >>ecb, '<HTML><BODY>Finished running test <i>', test_name, '</i>'
  32.         print >>ecb, '<pre>'
  33.         print >>ecb, result
  34.         print >>ecb, '</pre>'
  35.         print >>ecb, '</BODY></HTML>'
  36.         ecb.DoneWithSession()
  37.  
  38.     
  39.     def test1(self, ecb):
  40.         
  41.         try:
  42.             ecb.GetServerVariable('foo bar')
  43.             raise RuntimeError, 'should have failed!'
  44.         except ExtensionError:
  45.             err = None
  46.  
  47.         return 'worked!'
  48.  
  49.     
  50.     def test_long_vars(self, ecb):
  51.         qs = ecb.GetServerVariable('QUERY_STRING')
  52.         expected_query = 'x' * 8500
  53.         if len(qs) == 0:
  54.             me = ecb.GetServerVariable('URL')
  55.             headers = 'Location: ' + me + '?' + expected_query + '\r\n\r\n'
  56.             ecb.SendResponseHeaders('301 Moved', headers)
  57.             ecb.DoneWithSession()
  58.             return None
  59.         if qs == expected_query:
  60.             return 'Total length of variable is %d - test worked!' % (len(qs),)
  61.         return 'Unexpected query portion!  Got %d chars, expected %d' % (len(qs), len(expected_query))
  62.  
  63.     
  64.     def test_unicode_vars(self, ecb):
  65.         ver = float(ecb.GetServerVariable('SERVER_SOFTWARE').split('/')[1])
  66.         if ver < 6:
  67.             return 'This is IIS version %g - unicode only works in IIS6 and later' % ver
  68.         us = ecb.GetServerVariable('UNICODE_SERVER_NAME')
  69.         if not isinstance(us, unicode):
  70.             raise RuntimeError, 'unexpected type!'
  71.         isinstance(us, unicode)
  72.         if us != unicode(ecb.GetServerVariable('SERVER_NAME')):
  73.             raise RuntimeError, 'Unicode and non-unicode values were not the same'
  74.         us != unicode(ecb.GetServerVariable('SERVER_NAME'))
  75.         return 'worked!'
  76.  
  77.  
  78.  
  79. def __ExtensionFactory__():
  80.     return Extension()
  81.  
  82. if __name__ == '__main__':
  83.     from isapi.install import *
  84.     params = ISAPIParameters()
  85.     sm = [
  86.         ScriptMapParams(Extension = '*', Flags = 0)]
  87.     vd = VirtualDirParameters(Name = 'pyisapi_test', Description = Extension.__doc__, ScriptMaps = sm, ScriptMapUpdate = 'replace')
  88.     params.VirtualDirs = [
  89.         vd]
  90.     HandleCommandLine(params)
  91.  
  92.