On Wed, Apr 15, 2009 at 10:38:41AM -0700, Mike Orr wrote: > > On Wed, Apr 15, 2009 at 3:41 AM, Marius Gedminas <[email protected]> wrote: > > On Tue, Apr 14, 2009 at 10:22:08AM +0200, Eric Lemoine wrote: > >> I want to use > >> > >> [server:main] > >> use = egg:Paste#http > >> host = 0.0.0.0 > >> port = 0 > >> > >> so that my Pylons app's port number is assigned for me. > >> > >> Now, from my app's make_app() function do I have a way to know what > >> port number has actually been assigned? > > > > I don't think so: > > > > * the server is not necessarily created/configured when the > > environment calls your make_app > > > > * you can use the WSGI app with all kinds of servers, not all of which > > are based on TCP/IP (think CGI) > > > > But when you're actually processing a request, you should find the port > > number in the WSGI environment (SERVER_PORT, specifically). > > Does Python actually support port 0? And does the socket object > expose the port chosen?
Yes and yes (via socketobj.getsockname()). Marius Gedminas -- If you can't understand it, it is intuitively obvious.
signature.asc
Description: Digital signature
