Robert Brewer avatar Robert Brewer committed 1d8fc49

Changed server.start to server.quickstart, and server.start_all to server.start.

Comments (0)

Files changed (19)

 def quickstart(root, script_name="", conf=None):
     """Mount the given app, start the engine and builtin server, then block."""
     tree.mount(root, script_name, conf)
-    server.start()
+    server.quickstart()
     engine.start()
 
 try:
         self.httpservers = {}
         self.interrupt = None
     
-    def start(self, server=None):
-        """Main function. MUST be called from the main thread."""
-        self.interrupt = None
+    def quickstart(self, server=None):
+        """Main function for quick starts. MUST be called from the main thread.
+        
+        This function works like CherryPy 2's server.start(). It loads and
+        starts an httpserver based on the given server object, if any, and
+        config entries.
+        """
         httpserver, bind_addr = self.httpserver_from_config(server)
         self.httpservers[httpserver] = bind_addr
-        self._start_http(httpserver)
+        self.start()
     
     def httpserver_from_config(self, httpserver=None):
         """Return a (httpserver, bind_addr) pair based on config settings."""
         else:
             return httpserver, conf('server.socket_file')
     
-    def start_all(self):
+    def start(self):
         """Start all registered HTTP servers."""
+        self.interrupt = None
         for httpserver in self.httpservers:
             self._start_http(httpserver)
     
     def restart(self):
         """Restart the HTTP server."""
         self.stop()
-        self.interrupt = None
-        self.start_all()
+        self.start()
 
 
 def check_port(host, port):
     coverage.cache_default = path
     
     import cherrypy
-    cherrypy.tree.mount(CoverStats())
     cherrypy.config.update({'server.socket_port': port,
                             'server.thread_pool': 10,
                             'environment': "production",
                             })
-    cherrypy.server.start()
-    cherrypy.engine.start()
+    cherrypy.quickstart(CoverStats())
 
 if __name__ == "__main__":
     serve(*tuple(sys.argv[1:]))
 
 def serve(path=None, port=8080):
     import cherrypy
-    cherrypy.tree.mount(Profiler(path))
     cherrypy.config.update({'server.socket_port': int(port),
                             'server.thread_pool': 10,
                             'environment': "production",
                             })
-    cherrypy.server.start()
-    cherrypy.engine.start()
+    cherrypy.quickstart(Profiler(path))
 
 
 if __name__ == "__main__":

test/benchmark.py

             cherrypy.server.request_class = NullRequest
             cherrypy.server.response_class = NullResponse
         
-        cherrypy.server.start()
+        cherrypy.server.quickstart()
         # This will block
         cherrypy.engine.start_with_callback(run)
     """
     cherrypy.config.reset()
     setConfig(conf)
-    cherrypy.server.start(server)
+    cherrypy.server.quickstart(server)
     cherrypy.engine.start_with_callback(_run_test_suite_thread,
                                         args=(moduleNames, conf))
 
         conf = {}
     setConfig(conf)
     try:
-        cherrypy.server.start()
+        cherrypy.server.quickstart()
         cherrypy.engine.start_with_callback(_test_main_thread)
     except KeyboardInterrupt:
         cherrypy.server.stop()

test/test_session_concurrency.py

     data_dict[index] = int(data)
 
 # Start server
-cherrypy.server.start()
+cherrypy.server.quickstart()
 thread.start_new_thread(cherrypy.engine.start, ())
 
 # Start client

test/test_states.py

         self.assertEqual(len(db_connection.threads), 0)
         
         # Test server start
-        cherrypy.server.start(self.server_class)
+        cherrypy.server.quickstart(self.server_class)
         cherrypy.engine.start(blocking=False)
         self.assertEqual(cherrypy.engine.state, 1)
         
         cherrypy.server.stop()
     
     def test_1_Restart(self):
-        cherrypy.server.start(self.server_class)
+        cherrypy.server.start()
         cherrypy.engine.start(blocking=False)
         
         # The db_connection should be running now
             # Raise a keyboard interrupt in the HTTP server's main thread.
             # We must start the server in this, the main thread
             cherrypy.engine.start(blocking=False)
-            cherrypy.server.start(self.server_class)
-            cherrypy.server.httpservers.values()[0].interrupt = KeyboardInterrupt
+            cherrypy.server.start()
+            cherrypy.server.httpservers.keys()[0].interrupt = KeyboardInterrupt
             while cherrypy.engine.state != 0:
                 time.sleep(0.1)
             
             # This should raise a BadStatusLine error, since the worker
             # thread will just die without writing a response.
             cherrypy.engine.start(blocking=False)
-            cherrypy.server.start(self.server_class)
+            cherrypy.server.start()
             
             from httplib import BadStatusLine
             try:

test/test_states_demo.py

                             "environment": "development",
                             })
     cherrypy.quickstart(Root())
- 
+    

tutorial/bonus-sqlobject.py

 
 print "If you're running this application for the first time, please go to http://localhost:8080/reset once in order to create the database!"
 
-cherrypy.tree.mount(ContactManager())
-cherrypy.server.start()
-cherrypy.engine.start()
+cherrypy.quickstart(ContactManager())

tutorial/tut02_expose_methods.py

 if __name__ == '__main__':
     import os.path
     cherrypy.config.update(os.path.join(os.path.dirname(__file__), 'tutorial.conf'))
-    cherrypy.server.start()
+    cherrypy.server.quickstart()
     cherrypy.engine.start()
 

tutorial/tut03_get_and_post.py

 if __name__ == '__main__':
     import os.path
     cherrypy.config.update(os.path.join(os.path.dirname(__file__), 'tutorial.conf'))
-    cherrypy.server.start()
+    cherrypy.server.quickstart()
     cherrypy.engine.start()

tutorial/tut04_complex_site.py

 if __name__ == '__main__':
     import os.path
     cherrypy.config.update(os.path.join(os.path.dirname(__file__), 'tutorial.conf'))
-    cherrypy.server.start()
+    cherrypy.server.quickstart()
     cherrypy.engine.start()
 

tutorial/tut05_derived_objects.py

 if __name__ == '__main__':
     import os.path
     cherrypy.config.update(os.path.join(os.path.dirname(__file__), 'tutorial.conf'))
-    cherrypy.server.start()
+    cherrypy.server.quickstart()
     cherrypy.engine.start()
 

tutorial/tut06_default_method.py

 if __name__ == '__main__':
     import os.path
     cherrypy.config.update(os.path.join(os.path.dirname(__file__), 'tutorial.conf'))
-    cherrypy.server.start()
+    cherrypy.server.quickstart()
     cherrypy.engine.start()
 

tutorial/tut07_sessions.py

 if __name__ == '__main__':
     import os.path
     cherrypy.config.update(os.path.join(os.path.dirname(__file__), 'tutorial.conf'))
-    cherrypy.server.start()
+    cherrypy.server.quickstart()
     cherrypy.engine.start()
 

tutorial/tut08_generators_and_yield.py

 if __name__ == '__main__':
     import os.path
     cherrypy.config.update(os.path.join(os.path.dirname(__file__), 'tutorial.conf'))
-    cherrypy.server.start()
+    cherrypy.server.quickstart()
     cherrypy.engine.start()
 

tutorial/tut09_files.py

     import os.path
     # Start the CherryPy server.
     cherrypy.config.update(os.path.join(os.path.dirname(__file__), 'tutorial.conf'))
-    cherrypy.server.start()
+    cherrypy.server.quickstart()
     cherrypy.engine.start()

tutorial/tut10_http_errors.py

 if __name__ == '__main__':
     # Start the CherryPy server.
     cherrypy.config.update(os.path.join(os.path.dirname(__file__), 'tutorial.conf'))
-    cherrypy.server.start()
+    cherrypy.server.quickstart()
     cherrypy.engine.start()
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.