Robert Brewer avatar Robert Brewer committed 190f8e1

Fix for #756 (Deprecate server.quickstart):

* server.quickstart now does nothing but raise a warning.
* Made 'root' argument to cherrypy.quickstart optional (to make tutorials easier, but it applies broadly).
* Removed all calls to server.quickstart.

Comments (0)

Files changed (13)

cherrypy/__init__.py

 server.subscribe()
 
 
-def quickstart(root, script_name="", config=None):
+def quickstart(root=None, script_name="", config=None):
     """Mount the given root, start the builtin server (and engine), then block.
     
     root: an instance of a "controller class" (a collection of page handler
     """
     if config:
         _global_conf_alias.update(config)
-    tree.mount(root, script_name, config)
+    
+    if root is not None:
+        tree.mount(root, script_name, config)
     
     signal_handler.subscribe()
     engine.start()

cherrypy/_cpserver.py

 """Manage HTTP servers with CherryPy."""
 
 import socket
+import warnings
 
 import cherrypy
 from cherrypy.lib import attributes
     quickstart. For example:
     
         cherrypy.server.socket_port = 80
-        cherrypy.server.quickstart()
-    
-    If you want to use an HTTP server other than the default, create it
-    and pass it to quickstart:
-    
-        s = MyCustomWSGIServer(wsgiapp, port=8080)
-        cherrypy.server.quickstart(s)
+        cherrypy.quickstart()
     """
     
     socket_port = 8080
         ServerAdapter.__init__(self, cherrypy.engine)
     
     def quickstart(self, server=None):
-        """Start from defaults. 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 provided)
-        and attributes of self.
-        """
-        self.httpserver, self.bind_addr = self.httpserver_from_self(server)
-        self.start()
+        """This does nothing now and will be removed in 3.2."""
+        warnings.warn('quickstart does nothing now and will be removed in '
+                      '3.2. Call cherrypy.engine.start() instead.',
+                      DeprecationWarning)
     
     def httpserver_from_self(self, httpserver=None):
         """Return a (httpserver, bind_addr) pair based on self attributes."""

cherrypy/test/benchmark.py

             cherrypy.server.request_class = NullRequest
             cherrypy.server.response_class = NullResponse
         
-        cherrypy.server.quickstart()
         # This will block
         cherrypy.engine.start_with_callback(run)

cherrypy/test/helper.py

     if conf is None:
         conf = {'server.socket_host': '127.0.0.1'}
     setConfig(conf)
-    cherrypy.server.quickstart()
     cherrypy.engine.start_with_callback(_test_main_thread)
     cherrypy.engine.block()
 

cherrypy/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.quickstart()
-    cherrypy.engine.start()
-    cherrypy.engine.block()
+    thisdir = os.path.dirname(__file__)
+    cherrypy.quickstart(config=os.path.join(thisdir, 'tutorial.conf'))
 

cherrypy/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.quickstart()
-    cherrypy.engine.start()
-    cherrypy.engine.block()
+    thisdir = os.path.dirname(__file__)
+    cherrypy.quickstart(config=os.path.join(thisdir, 'tutorial.conf'))

cherrypy/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.quickstart()
-    cherrypy.engine.start()
-    cherrypy.engine.block()
+    thisdir = os.path.dirname(__file__)
+    cherrypy.quickstart(config=os.path.join(thisdir, 'tutorial.conf'))
 

cherrypy/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.quickstart()
-    cherrypy.engine.start()
-    cherrypy.engine.block()
-
+    thisdir = os.path.dirname(__file__)
+    cherrypy.quickstart(config=os.path.join(thisdir, 'tutorial.conf'))

cherrypy/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.quickstart()
-    cherrypy.engine.start()
-    cherrypy.engine.block()
-
+    thisdir = os.path.dirname(__file__)
+    cherrypy.quickstart(config=os.path.join(thisdir, 'tutorial.conf'))

cherrypy/tutorial/tut07_sessions.py

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

cherrypy/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.quickstart()
-    cherrypy.engine.start()
-    cherrypy.engine.block()
-
+    thisdir = os.path.dirname(__file__)
+    cherrypy.quickstart(config=os.path.join(thisdir, 'tutorial.conf'))

cherrypy/tutorial/tut09_files.py

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

cherrypy/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.quickstart()
-    cherrypy.engine.start()
-    cherrypy.engine.block()
+    import os.path
+    thisdir = os.path.dirname(__file__)
+    cherrypy.quickstart(config=os.path.join(thisdir, 'tutorial.conf'))
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.