Download Install Tutorial Docs FAQ Tools WikiLicense Team IRC Planet Involvement Shop Book

Changeset 943

Show
Ignore:
Timestamp:
01/26/06 06:58:24
Author:
rdelon
Message:

Deprecated "initOnly" and "serverClass". New names are "init_only" and "server_class"

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/cherrypy/_cpserver.py

    r905 r943  
    4343        self.onStopThreadList = [] 
    4444     
    45     def start(self, initOnly=False, serverClass=_missing): 
     45    def start(self, init_only = False, server_class = _missing, 
     46                initOnly = None, serverClass = None): 
    4647        """Main function. MUST be called from the main thread. 
    4748         
     
    4950        Set serverClass to None to skip starting any HTTP server. 
    5051        """ 
     52         
     53        # Read old variable names for backward compatibility 
     54        if initOnly is not None: 
     55            init_only = initOnly 
     56        if serverClass is not None: 
     57            server_class = serverClass 
     58 
    5159        self.state = STARTING 
    5260        self.interrupt = None 
     
    5462        conf = cherrypy.config.get 
    5563         
    56         if serverClass is _missing: 
    57             serverClass = conf("server.class", _missing) 
    58         if serverClass is _missing: 
     64        if server_class is _missing: 
     65            server_class = conf("server.class", _missing) 
     66        if server_class is _missing: 
    5967            import _cpwsgi 
    60             serverClass = _cpwsgi.WSGIServer 
    61         elif serverClass and isinstance(serverClass, basestring): 
     68            server_class = _cpwsgi.WSGIServer 
     69        elif server_class and isinstance(server_class, basestring): 
    6270            # Dynamically load the class from the given string 
    63             serverClass = cptools.attributes(serverClass) 
    64          
    65         self.blocking = not initOnly 
    66         self.httpserverclass = serverClass 
     71            server_class = cptools.attributes(server_class) 
     72         
     73        self.blocking = not init_only 
     74        self.httpserverclass = server_class 
    6775         
    6876        # Hmmm...we *could* check config in _start instead, but I think 
     
    7078        check_config() 
    7179         
    72         # Autoreload, but check serverClass. If None, we're not starting 
     80        # Autoreload, but check server_class. If None, we're not starting 
    7381        # our own webserver, and therefore could do Very Bad Things when 
    7482        # autoreload calls sys.exit. 
    75         if serverClass is not None: 
     83        if server_class is not None: 
    7684            if conf('autoreload.on', False): 
    7785                try: 
     
    258266     
    259267    def start_with_callback(self, func, args=None, kwargs=None, 
    260                             serverClass=_missing): 
     268                            server_class = _missing, serverClass = None): 
    261269        """Start, then callback the given func in a new thread.""" 
     270 
     271        # Read old name for backward compatibility 
     272        if serverClass is not None: 
     273            server_class = None 
     274 
    262275        if args is None: 
    263276            args = () 
     
    271284        threading.Thread(target=_callback, args=args, kwargs=kwargs).start() 
    272285         
    273         self.start(serverClass=serverClass) 
     286        self.start(server_class = server_class) 
    274287 
    275288 
  • trunk/cherrypy/test/helper.py

    r917 r943  
    199199    setConfig(conf) 
    200200    cherrypy.server.start_with_callback(_run_test_suite_thread, 
    201                                         args=(moduleNames, conf), 
    202                                         serverClass=server) 
     201            args = (moduleNames, conf), server_class = server) 
    203202 
    204203def _run_test_suite_thread(moduleNames, conf): 
     
    219218        conf = {} 
    220219    setConfig(conf) 
    221     cherrypy.server.start_with_callback(_test_main_thread, serverClass=server) 
     220    cherrypy.server.start_with_callback(_test_main_thread, 
     221            server_class = server) 
    222222 
    223223def _test_main_thread(): 
  • trunk/cherrypy/test/test_noserver.py

    r778 r943  
    2828 
    2929cherrypy.config.update({"server.environment": "production"}) 
    30 cherrypy.server.start(serverClass=None) 
     30cherrypy.server.start(server_class = None) 
    3131 
  • trunk/cherrypy/test/test_states.py

    r897 r943  
    6565         
    6666        # Test server start 
    67         cherrypy.server.start(True, self.serverClass) 
     67        cherrypy.server.start(True, self.server_class) 
    6868        self.assertEqual(cherrypy.server.state, 1) 
    6969         
    70         if self.serverClass: 
     70        if self.server_class: 
    7171            host = cherrypy.config.get('server.socket_host') 
    7272            port = cherrypy.config.get('server.socket_port') 
     
    9494     
    9595    def test_1_Restart(self): 
    96         cherrypy.server.start(True, self.serverClass) 
     96        cherrypy.server.start(True, self.server_class) 
    9797         
    9898        # The db_connection should be running now 
     
    129129     
    130130    def test_2_KeyboardInterrupt(self): 
    131         if self.serverClass: 
     131        if self.server_class: 
    132132             
    133133            # Raise a keyboard interrupt in the HTTP server's main thread. 
     
    138138             
    139139            # We must start the server in this, the main thread 
    140             cherrypy.server.start(False, self.serverClass) 
     140            cherrypy.server.start(False, self.server_class) 
    141141            # Time passes... 
    142142            self.assertEqual(cherrypy.server.httpserver, None) 
     
    156156            threading.Thread(target=interrupt).start() 
    157157             
    158             cherrypy.server.start(False, self.serverClass) 
     158            cherrypy.server.start(False, self.server_class) 
    159159            # Time passes... 
    160160            self.assertEqual(cherrypy.server.httpserver, None) 
     
    166166    def test_3_ConfigErrors(self): 
    167167        cherrypy.config.update({'server.environment': 'destruction'}) 
     168         
    168169        try: 
    169170            self.assertRaises(cherrypy.WrongConfigValue, 
    170                               cherrypy.server.start, True, self.serverClass) 
     171                    cherrypy.server.start, True, self.server_class) 
    171172        finally: 
    172173            cherrypy.server.stop() 
     
    177178def run(server, conf): 
    178179    helper.setConfig(conf) 
    179     ServerStateTests.serverClass = server 
     180    ServerStateTests.server_class = server 
    180181    suite = helper.CPTestLoader.loadTestsFromTestCase(ServerStateTests) 
    181182    try: 
  • trunk/cherrypy/test/test_xmlrpc_filter.py

    r856 r943  
    137137if __name__ == '__main__': 
    138138    from cherrypy import _cpwsgi 
    139     serverClass = _cpwsgi.WSGIServer 
    140     helper.testmain(serverClass) 
     139    server_class = _cpwsgi.WSGIServer 
     140    helper.testmain(server_class) 
    141141 
  • trunk/docs/book/xml/apireference.xml

    r942 r943  
    186186        <title>cherrypy.server</title> 
    187187        <section> 
    188             <title>cherrypy.server.start(initOnly=False, serverClass=_missing)</title> 
     188            <title>cherrypy.server.start(init_only = False, server_class = _missing)</title> 
    189189            <para>Start the CherryPy Server. Simple websites may call this without any arguments, to 
    190             run the default server. If initOnly is False (the default), this function will block 
     190            run the default server. If init_only is False (the default), this function will block 
    191191            until KeyboardInterrupt or SystemExit is raised, so that the process will persist. When 
    192192            using one of the built-in HTTP servers, you should leave this set to False. You should 
     
    194194            (for example, when using Apache and mod_python with CherryPy), in which case the foreign 
    195195            HTTP server should do its own process-management.</para> 
    196             <para>Use the serverClass argument to specify that you wish to use an HTTP server other 
     196            <para>Use the server_class argument to specify that you wish to use an HTTP server other 
    197197            than the default, built-in WSGIServer. If missing, config.get("server.class") will be 
    198198            checked for an alternate value; otherwise, the default is used. Possible alternate values 
     
    217217                <listitem> 
    218218                    <para><code>None</code>: this will not load any HTTP server. Note that this is 
    219                     not the default; the default (if serverClass is not given) is to load the 
     219                    not the default; the default (if server_class is not given) is to load the 
    220220                    WSGIServer.</para> 
    221221                </listitem> 
     
    225225            </itemizedlist> 
    226226            <para>You <emphasis>must</emphasis> call this function from Python's main thread, and set 
    227             initOnly to False, if you want CherryPy to shut down when KeyboardInterrupt or SystemExit 
     227            init_only to False, if you want CherryPy to shut down when KeyboardInterrupt or SystemExit 
    228228            are raised (including Ctrl-C). The only time you might want to do otherwise is if you run 
    229229            CherryPy as a Windows service, or as an extension to, say, mod_python, and even then, you 
     
    232232        <section> 
    233233            <title>cherrypy.server.blocking</title> 
    234             <para>If the "initOnly" argument to server.start is True, this will be False, and 
     234            <para>If the "init_only" argument to server.start is True, this will be False, and 
    235235            vice-versa.</para> 
    236236        </section> 
     
    274274        <section> 
    275275            <title>cherrypy.server.start_with_callback(func, args=(), kwargs={}, 
    276             serverClass=_missing)</title> 
     276            server_class = _missing)</title> 
    277277            <para>Since server.start usually blocks, use this to easily run another function in a new 
    278278            thread. It starts the new thread and then runs server.start. The new thread automatically 

Hosted by WebFaction

Log in as guest/cpguest to create tickets