Changeset 405
- Timestamp:
- 07/04/05 13:29:09
- Files:
-
- trunk/cherrypy/__init__.py (modified) (1 diff)
- trunk/cherrypy/_cperror.py (modified) (1 diff)
- trunk/cherrypy/_cpwsgi.py (modified) (3 diffs)
- trunk/cherrypy/lib/profiler.py (modified) (1 diff)
- trunk/cherrypy/server.py (modified) (6 diffs)
- trunk/cherrypy/test/test.py (modified) (2 diffs)
- trunk/cherrypy/test/test_baseurl_filter.py (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/cherrypy/__init__.py
r395 r405 38 38 import server 39 39 40 # Use a flag to indicate the state of the cherrypy application server. 41 # 0 = Not started 42 # None = In process of starting 43 # 1 = Started, ready to receive requests 44 _appserver_state = 0 40 45 _httpserver = None 41 46 trunk/cherrypy/_cperror.py
r385 r405 35 35 class InternalError(Error): 36 36 """ Error that should never happen """ 37 pass 38 39 class NotReady(Error): 40 """A request was made before the app server has been started.""" 37 41 pass 38 42 trunk/cherrypy/_cpwsgi.py
r388 r405 85 85 # Both IIS and Apache set REMOTE_USER, when possible. 86 86 cherrypy.request.login = (environ.get('LOGON_USER') 87 or environ.get('REMOTE_USER') or None)87 or environ.get('REMOTE_USER') or None) 88 88 cherrypy.request.multithread = environ['wsgi.multithread'] 89 89 cherrypy.request.multiprocess = environ['wsgi.multiprocess'] … … 96 96 ) 97 97 start_response(cherrypy.response.status, cherrypy.response.headers) 98 except: 99 tb = _cputil.formatExc() 100 cherrypy.log(tb) 101 s, h, b = _cphttptools.bareError(tb) 102 start_response(s, h, sys.exc_info()) 103 104 try: 98 105 for chunk in cherrypy.response.body: 99 106 # WSGI requires all data to be of type "str". This coercion should … … 109 116 # so don't call start_response (which, according to PEP 333, 110 117 # may raise its own error at that point). 111 ## start_response(s, h, sys.exc_info())112 118 for chunk in b: 113 119 yield str(chunk) trunk/cherrypy/lib/profiler.py
r382 r405 140 140 import cherrypy 141 141 cherrypy.root = Profiler(path) 142 cherrypy.config.update({'global': {'server.s erverPort': port,142 cherrypy.config.update({'global': {'server.socketPort': port, 143 143 'server.threadPool': 10, 144 144 'server.environment': "production", trunk/cherrypy/server.py
r391 r405 47 47 onStopThreadList = [] 48 48 49 49 50 def start(initOnly=False, serverClass=None): 50 51 if cherrypy.config.get("server.environment") == "development": … … 66 67 """ 67 68 69 # Use a flag to indicate the state of the cherrypy application server. 70 # 0 = Not started 71 # None = In process of starting 72 # 1 = Started, ready to receive requests 73 cherrypy._appserver_state = None 74 68 75 # Output config options to log 69 76 if cherrypy.config.get("server.logConfigOptions", True): … … 96 103 cherrypy.profiler = None 97 104 98 if not initOnly: 105 if initOnly: 106 cherrypy._appserver_state = 1 107 else: 99 108 run_server(serverClass) 100 109 … … 127 136 # Start the http server. 128 137 try: 138 cherrypy._appserver_state = 1 129 139 cherrypy._httpserver.start() 130 140 except (KeyboardInterrupt, SystemExit): … … 177 187 """ 178 188 189 if cherrypy._appserver_state == 0: 190 raise cherrypy.NotReady("No thread has called cherrypy.server.start().") 191 elif cherrypy._appserver_state == None: 192 raise cherrypy.NotReady("cherrypy.server.start() encountered errors.") 193 179 194 threadID = threading._get_ident() 180 195 if threadID not in seen_threads: … … 210 225 for func in cherrypy.server.onStopServerList: 211 226 func() 227 212 228 cherrypy._httpserver = None 229 cherrypy._appserver_state = 0 trunk/cherrypy/test/test.py
r382 r405 141 141 print 142 142 143 import cherrypy 144 from cherrypy.test import helper 145 146 class NotReadyTest(unittest.TestCase): 147 def testNotReadyError(self): 148 # Without having called "cherrypy.server.start()", we should 149 # get a NotReady error 150 self.assertRaises(cherrypy.NotReady, helper.request, "/") 151 CPTestRunner(verbosity=2).run(NotReadyTest("testNotReadyError")) 152 143 153 testList = [ 144 154 'test_baseurl_filter', … … 154 164 'test_virtualhost_filter', 155 165 ] 156 157 import cherrypy158 from cherrypy.test import helper159 166 160 167 server_conf = {'server.socketHost': helper.HOST, trunk/cherrypy/test/test_baseurl_filter.py
r382 r405 40 40 'global': { 41 41 'server.environment': 'production', 42 'server.logToScreen': False, 42 43 'baseUrlFilter.on': True, 43 44 'baseUrlFilter.baseUrl': 'http://www.mydomain.com'

