Commits

Anonymous committed 18c898b

Addresses #480.

init_only can now be set in the config (server.init_only). server.class already existed. server.instance can also be set in the config. It corresponds to the "server" parameter in the cherrypy.server.start() method.

Also added "embedded" server environment to simplify running CP embedded in mod_python, FastCGI, another WSGI server, etc.

  • Participants
  • Parent commits 85731af
  • Branches cherrypy

Comments (0)

Files changed (3)

             server_class = kwargs['serverClass']
         
         conf = cherrypy.config.get
+        
+        if not init_only:
+            init_only = conf('server.init_only', False)
+        
+        if server is None:
+            server = conf('server.instance', None)
         if server is None:
             if server_class is _missing:
                 server_class = conf("server.class", _missing)
             if server_class is not None:
                 self.httpserver = server_class()
         else:
+            if isinstance(server, basestring):
+                server = cptools.attributes(server)
             self.httpserverclass = server.__class__
             self.httpserver = server
         
         'server.show_tracebacks': False,
         'server.log_request_headers': False,
         },
+    "embedded": {
+        'autoreload.on': False,
+        'server.log_to_screen': False,
+        'server.init_only': True,
+        'server.class': None,
+        },
     }
 
 def update(updateMap=None, file=None, overwrite=True, baseurl=""):

test/test_config.py

         return str(cherrypy.config.get(key, "None"))
     index.exposed = True
     prod = index
-
+    embed = index
 
 cherrypy.tree.mount(Root())
 cherrypy.root.foo = Foo()
 
 _env_conf = {'/': {'server.environment': 'development'},
              '/prod': {'server.environment': 'production'},
+             '/embed': {'server.environment': 'embedded'},
              }
 cherrypy.tree.mount(Env(), "/env", _env_conf)
 
         for key, val in cherrypy.config.environments['production'].iteritems():
             self.getPage("/env/prod/?key=" + key)
             self.assertBody(str(val))
+        for key, val in cherrypy.config.environments['embedded'].iteritems():
+            self.getPage("/env/embed/?key=" + key)
+            data = self.body.split("\n")[0]
+            self.assertEqual(data, str(val))
 
 
 if __name__ == '__main__':