Sort of. When first making 3.0, I hadn't yet dreamed of the pub/sub
approach of the WSPBus, and I made the poor design choice of having
cherrypy.server try to be a single controller for multiple HTTP servers
in the same process. So yes, that particular design was phased out.
With the new bus in 3.1, however, it should be as simple as:
cherrypy.server2 = s = _cpserver.Server()
s.socket_port = 443
s.ssl_certificate = '/path/to/cert'
s.ssl_private_key = '/path/to/privkey'
s.subscribe()
If you would rather set the port, etc. in config, you would just need to
add a new config namespace:
cherrypy.config.namespaces['server2'] = \
lambda k, v: setattr(cherrypy.server2, k, v)
You would still need to execute some code:
cherrypy.server2 = _cpserver.Server()
cherrypy.server2.subscribe()
...but you could then at least move these lines into config:
[global]
server2.socket_port = 443
server2.ssl_certificate = '/path/to/cert'
server2.ssl_private_key = '/path/to/privkey'
Hmm. Maybe I should add an "on" property to the Server (and perhaps
other Bus plugins) that subscribes it when True and unsubscribes it when
False...
Robert Brewer
fuma...@aminus.org
There's no point in keeping both initializations. You might as well
drop line 1468 altogether and make the __init__ code do this:
self.environ = {}
And, in fact, that's exactly how it used to be done. The code was
changed in rev 1677 by fumanchu. Hopefully, someone will chime in with
a discussion on the relative merits.
As an unrelated side note, remember that "{}" and "None" are both false
values as far as "if not" is concerned. If you don't need to tell the
difference, then you can just leave it as "environ = {}". If you do
need to tell the difference, then the "if" needs to be "if self.environ
is not None:".
--
Tim Roberts, ti...@probo.com
Providenza & Boekelheide, Inc.
Sorry about that, Richard.
> > Here is the change so they
> > have separate 'environ's.
> >
> >
> > diff -ru cherrypyp1/wsgiserver/__init__.py cherrypyp2/wsgiserver/
> > __init__.py
> > --- cherrypyp1/wsgiserver/__init__.py 2008-12-01 13:36:18
+1300
> > +++ cherrypyp2/wsgiserver/__init__.py 2008-12-03 12:56:33
+1300
> > @@ -1464,7 +1464,7 @@
> > nodelay = True
> >
> > ConnectionClass = HTTPConnection
> > - environ = {}
> > + environ = None
> >
> > # Paths to certificate and private key files
> > ssl_certificate = None
> > @@ -1474,6 +1474,9 @@
> > max=-1, request_queue_size=5, timeout=10,
> > shutdown_timeout=5):
> > self.requests = ThreadPool(self, min=numthreads or 1,
> > max=max)
> >
> > + if not self.environ:
> > + self.environ = {}
I think I'd rather allow inherited values from the class. So the change
would instead be:
@@ -1474,6 +1474,9 @@
max=-1, request_queue_size=5, timeout=10,
shutdown_timeout=5):
self.requests = ThreadPool(self, min=numthreads or 1,
max=max)
+ self.environ = self.environ.copy()
This is how HTTPConnection does it (and Request.error_pages, namespace,
etc). It can be helpful for subclass authors to be able to specify
environ entries at the class level.
> > +
> > if callable(wsgi_app):
> > # We've been handed a single wsgi_app, in CP-2.1 style.
> > # Assume it's mounted at "".
>
> There's no point in keeping both initializations. You might as well
> drop line 1468 altogether and make the __init__ code do this:
> self.environ = {}
>
> And, in fact, that's exactly how it used to be done. The code was
> changed in rev 1677 by fumanchu. Hopefully, someone will chime in
with
> a discussion on the relative merits.
It's helpful when browsing classes for the class itself to declare its
instances' attributes. For example, in many IDE's, you can type:
>>> from cherrypy import wsgiserver
>>> wsgiserver.CherryPyWSGIServer.
...and have "environ" show up in a tooltip.
Robert Brewer
fuma...@aminus.org