Changeset 50102 in webkit
- Timestamp:
- Oct 26, 2009 3:10:26 PM (15 years ago)
- Location:
- trunk/WebKitTools
- Files:
-
- 7 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/WebKitTools/ChangeLog
r50091 r50102 1 2009-10-26 Yuzo Fujishima <yuzo@google.com> 2 3 Reviewed by Eric Seidel. 4 5 Upgrade pywebsocket to 0.4.1. This will make reusing LayoutTests/fast/js/resources easier, for example. 6 7 https://bugs.webkit.org/show_bug.cgi?id=30763 8 9 * pywebsocket/mod_pywebsocket/__init__.py: 10 * pywebsocket/mod_pywebsocket/dispatch.py: 11 * pywebsocket/mod_pywebsocket/headerparserhandler.py: 12 * pywebsocket/mod_pywebsocket/standalone.py: 13 * pywebsocket/setup.py: 14 * pywebsocket/test/test_dispatch.py: 15 1 16 2009-10-26 Carol Szabo <carol.szabo@nokia.com> 2 17 -
trunk/WebKitTools/pywebsocket/mod_pywebsocket/__init__.py
r49672 r50102 52 52 PythonHeaderParserHandler mod_pywebsocket.headerparserhandler 53 53 54 To limit the search for Web Socket handlers to a directory <scan_dir> 55 under <websock_handlers>, configure as follows: 56 57 PythonOption mod_pywebsocket.handler_scan <scan_dir> 58 59 <scan_dir> is useful in saving scan time when <websock_handlers> 60 contains many non-Web Socket handler files. 61 54 62 Example snippet of httpd.conf: 55 63 (mod_pywebsocket is in /websock_lib, Web Socket handlers are in -
trunk/WebKitTools/pywebsocket/mod_pywebsocket/dispatch.py
r49672 r50102 120 120 """ 121 121 122 def __init__(self, root_dir ):122 def __init__(self, root_dir, scan_dir=None): 123 123 """Construct an instance. 124 124 125 125 Args: 126 126 root_dir: The directory where handler definition files are 127 placed. 127 placed. 128 scan_dir: The directory where handler definition files are 129 searched. scan_dir must be a directory under root_dir, 130 including root_dir itself. If scan_dir is None, root_dir 131 is used as scan_dir. scan_dir can be useful in saving 132 scan time when root_dir contains many subdirectories. 128 133 """ 129 134 130 135 self._handlers = {} 131 136 self._source_warnings = [] 132 self._source_files_in_dir(root_dir) 137 if scan_dir is None: 138 scan_dir = root_dir 139 if not os.path.abspath(scan_dir).startswith(os.path.abspath(root_dir)): 140 raise DispatchError('scan_dir:%s must be a directory under ' 141 'root_dir:%s.' % (scan_dir, root_dir)) 142 self._source_files_in_dir(root_dir, scan_dir) 133 143 134 144 def source_warnings(self): … … 177 187 raise DispatchError('No handler for: %r' % request.ws_resource) 178 188 179 def _source_files_in_dir(self, root_dir): 180 """Source all the handler source files in the directory.""" 189 def _source_files_in_dir(self, root_dir, scan_dir): 190 """Source all the handler source files in the scan_dir directory. 191 192 The resource path is determined relative to root_dir. 193 """ 181 194 182 195 to_resource = _path_to_resource_converter(root_dir) 183 for path in _source_file_paths( root_dir):196 for path in _source_file_paths(scan_dir): 184 197 try: 185 198 handlers = _source(open(path).read()) -
trunk/WebKitTools/pywebsocket/mod_pywebsocket/headerparserhandler.py
r49672 r50102 46 46 _PYOPT_HANDLER_ROOT = 'mod_pywebsocket.handler_root' 47 47 48 # PythonOption to specify the handler scan directory. 49 # This must be a directory under the root directory. 50 # The default is the root directory. 51 _PYOPT_HANDLER_SCAN = 'mod_pywebsocket.handler_scan' 52 48 53 49 54 def _create_dispatcher(): … … 53 58 raise Exception('PythonOption %s is not defined' % _PYOPT_HANDLER_ROOT, 54 59 apache.APLOG_ERR) 55 dispatcher = dispatch.Dispatcher(_HANDLER_ROOT) 60 _HANDLER_SCAN = apache.main_server.get_options().get( 61 _PYOPT_HANDLER_SCAN, _HANDLER_ROOT) 62 dispatcher = dispatch.Dispatcher(_HANDLER_ROOT, _HANDLER_SCAN) 56 63 for warning in dispatcher.source_warnings(): 57 64 apache.log_error('mod_pywebsocket: %s' % warning, apache.APLOG_WARNING) -
trunk/WebKitTools/pywebsocket/mod_pywebsocket/standalone.py
r49672 r50102 37 37 Usage: 38 38 python standalone.py [-p <ws_port>] [-w <websock_handlers>] 39 [-s <scan_dir>] 39 40 [-d <document_root>] 40 41 … … 46 47 See __init__.py for details of <websock_handlers> and how to write Web Socket 47 48 handlers. If this path is relative, <document_root> is used as the base. 49 50 <scan_dir> is a path under the root directory. If specified, only the handlers 51 under scan_dir are scanned. This is useful in saving scan time. 48 52 49 53 Note: … … 163 167 self, WebSocketRequestHandler.options.use_tls) 164 168 self._dispatcher = dispatch.Dispatcher( 165 WebSocketRequestHandler.options.websock_handlers) 169 WebSocketRequestHandler.options.websock_handlers, 170 WebSocketRequestHandler.options.scan_dir) 166 171 self._print_warnings_if_any() 167 172 self._handshaker = handshake.Handshaker(self._request, … … 207 212 default='.', 208 213 help='Web Socket handlers root directory.') 214 parser.add_option('-s', '--scan_dir', dest='scan_dir', 215 default=None, 216 help=('Web Socket handlers scan directory. ' 217 'Must be a directory under websock_handlers.')) 209 218 parser.add_option('-d', '--document_root', dest='document_root', 210 219 default='.', … … 227 236 sys.exit(1) 228 237 238 if not options.scan_dir: 239 options.scan_dir = options.websock_handlers 240 229 241 WebSocketRequestHandler.options = options 230 242 WebSocketServer.options = options -
trunk/WebKitTools/pywebsocket/setup.py
r49672 r50102 57 57 packages=[_PACKAGE_NAME], 58 58 url='http://code.google.com/p/pywebsocket/', 59 version='0.4. 0',59 version='0.4.1', 60 60 ) 61 61 -
trunk/WebKitTools/pywebsocket/test/test_dispatch.py
r49672 r50102 46 46 _TEST_HANDLERS_DIR = os.path.join( 47 47 os.path.split(__file__)[0], 'testdata', 'handlers') 48 49 _TEST_HANDLERS_SUB_DIR = os.path.join(_TEST_HANDLERS_DIR, 'sub') 48 50 49 51 class DispatcherTest(unittest.TestCase): … … 107 109 108 110 def test_source_warnings(self): 109 dispatcher = dispatch.Dispatcher(_TEST_HANDLERS_DIR )111 dispatcher = dispatch.Dispatcher(_TEST_HANDLERS_DIR, None) 110 112 warnings = dispatcher.source_warnings() 111 113 warnings.sort() … … 127 129 self.assertEquals(expected, actual) 128 130 129 def test_ shake_hand(self):130 dispatcher = dispatch.Dispatcher(_TEST_HANDLERS_DIR )131 def test_do_extra_handshake(self): 132 dispatcher = dispatch.Dispatcher(_TEST_HANDLERS_DIR, None) 131 133 request = mock.MockRequest() 132 134 request.ws_resource = '/origin_check' … … 139 141 140 142 def test_transfer_data(self): 141 dispatcher = dispatch.Dispatcher(_TEST_HANDLERS_DIR )143 dispatcher = dispatch.Dispatcher(_TEST_HANDLERS_DIR, None) 142 144 request = mock.MockRequest(connection=mock.MockConn('')) 143 145 request.ws_resource = '/origin_check' … … 156 158 157 159 def test_transfer_data_no_handler(self): 158 dispatcher = dispatch.Dispatcher(_TEST_HANDLERS_DIR )160 dispatcher = dispatch.Dispatcher(_TEST_HANDLERS_DIR, None) 159 161 for resource in ['/blank', '/sub/non_callable', 160 162 '/sub/no_wsh_at_the_end', '/does/not/exist']: … … 171 173 172 174 def test_transfer_data_handler_exception(self): 173 dispatcher = dispatch.Dispatcher(_TEST_HANDLERS_DIR )175 dispatcher = dispatch.Dispatcher(_TEST_HANDLERS_DIR, None) 174 176 request = mock.MockRequest(connection=mock.MockConn('')) 175 177 request.ws_resource = '/sub/exception_in_transfer' … … 183 185 self.fail() 184 186 187 def test_scan_dir(self): 188 disp = dispatch.Dispatcher(_TEST_HANDLERS_DIR, None) 189 self.assertEqual(3, len(disp._handlers)) 190 self.failUnless(disp._handlers.has_key('/origin_check')) 191 self.failUnless(disp._handlers.has_key('/sub/exception_in_transfer')) 192 self.failUnless(disp._handlers.has_key('/sub/plain')) 193 194 def test_scan_sub_dir(self): 195 disp = dispatch.Dispatcher(_TEST_HANDLERS_DIR, _TEST_HANDLERS_SUB_DIR) 196 self.assertEqual(2, len(disp._handlers)) 197 self.failIf(disp._handlers.has_key('/origin_check')) 198 self.failUnless(disp._handlers.has_key('/sub/exception_in_transfer')) 199 self.failUnless(disp._handlers.has_key('/sub/plain')) 200 201 def test_scan_sub_dir_as_root(self): 202 disp = dispatch.Dispatcher(_TEST_HANDLERS_SUB_DIR, 203 _TEST_HANDLERS_SUB_DIR) 204 self.assertEqual(2, len(disp._handlers)) 205 self.failIf(disp._handlers.has_key('/origin_check')) 206 self.failIf(disp._handlers.has_key('/sub/exception_in_transfer')) 207 self.failIf(disp._handlers.has_key('/sub/plain')) 208 self.failUnless(disp._handlers.has_key('/exception_in_transfer')) 209 self.failUnless(disp._handlers.has_key('/plain')) 210 211 def test_scan_dir_must_under_root(self): 212 dispatch.Dispatcher('a/b', 'a/b/c') # OK 213 dispatch.Dispatcher('a/b///', 'a/b') # OK 214 self.assertRaises(dispatch.DispatchError, 215 dispatch.Dispatcher, 'a/b/c', 'a/b') 216 185 217 186 218 if __name__ == '__main__':
Note: See TracChangeset
for help on using the changeset viewer.