Back to index

moin  1.9.0~rc2
Public Member Functions
MoinMoin.support.flup.server.scgi.WSGIServer Class Reference
Inheritance diagram for MoinMoin.support.flup.server.scgi.WSGIServer:
Inheritance graph
[legend]
Collaboration diagram for MoinMoin.support.flup.server.scgi.WSGIServer:
Collaboration graph
[legend]

List of all members.

Public Member Functions

def __init__
def run

Detailed Description

SCGI/WSGI server. For information about SCGI (Simple Common Gateway
Interface), see http://www.mems-exchange.org/software/scgi/.

This server is similar to SWAP http://www.idyll.org/~t/www-tools/wsgi/,
another SCGI/WSGI server.

It differs from SWAP in that it isn't based on scgi.scgi_server and
therefore, it allows me to implement concurrency using threads. (Also,
this server was written from scratch and really has no other depedencies.)
Which server to use really boils down to whether you want multithreading
or forking. (But as an aside, I've found scgi.scgi_server's implementation
of preforking to be quite superior. So if your application really doesn't
mind running in multiple processes, go use SWAP. ;)

Definition at line 81 of file scgi.py.


Constructor & Destructor Documentation

def MoinMoin.support.flup.server.scgi.WSGIServer.__init__ (   self,
  application,
  scriptName = NoDefault,
  environ = None,
  multithreaded = True,
  multiprocess = False,
  bindAddress = ('localhost', 4000,
  umask = None,
  allowedServers = None,
  loggingLevel = logging.INFO,
  debug = False,
  kw 
)
scriptName is the initial portion of the URL path that "belongs"
to your application. It is used to determine PATH_INFO (which doesn't
seem to be passed in). An empty scriptName means your application
is mounted at the root of your virtual host.

environ, which must be a dictionary, can contain any additional
environment variables you want to pass to your application.

bindAddress is the address to bind to, which must be a string or
a tuple of length 2. If a tuple, the first element must be a string,
which is the host name or IPv4 address of a local interface. The
2nd element of the tuple is the port number. If a string, it will
be interpreted as a filename and a UNIX socket will be opened.

If binding to a UNIX socket, umask may be set to specify what
the umask is to be changed to before the socket is created in the
filesystem. After the socket is created, the previous umask is
restored.

allowedServers must be None or a list of strings representing the
IPv4 addresses of servers allowed to connect. None means accept
connections from anywhere.

loggingLevel sets the logging level of the module-level logger.

Definition at line 101 of file scgi.py.

00101 
00102                  loggingLevel=logging.INFO, debug=False, **kw):
00103         """
00104         scriptName is the initial portion of the URL path that "belongs"
00105         to your application. It is used to determine PATH_INFO (which doesn't
00106         seem to be passed in). An empty scriptName means your application
00107         is mounted at the root of your virtual host.
00108 
00109         environ, which must be a dictionary, can contain any additional
00110         environment variables you want to pass to your application.
00111 
00112         bindAddress is the address to bind to, which must be a string or
00113         a tuple of length 2. If a tuple, the first element must be a string,
00114         which is the host name or IPv4 address of a local interface. The
00115         2nd element of the tuple is the port number. If a string, it will
00116         be interpreted as a filename and a UNIX socket will be opened.
00117 
00118         If binding to a UNIX socket, umask may be set to specify what
00119         the umask is to be changed to before the socket is created in the
00120         filesystem. After the socket is created, the previous umask is
00121         restored.
00122 
00123         allowedServers must be None or a list of strings representing the
00124         IPv4 addresses of servers allowed to connect. None means accept
00125         connections from anywhere.
00126 
00127         loggingLevel sets the logging level of the module-level logger.
00128         """
00129         BaseSCGIServer.__init__(self, application,
00130                                 scriptName=scriptName,
00131                                 environ=environ,
00132                                 multithreaded=multithreaded,
00133                                 multiprocess=multiprocess,
00134                                 bindAddress=bindAddress,
00135                                 umask=umask,
00136                                 allowedServers=allowedServers,
00137                                 loggingLevel=loggingLevel,
00138                                 debug=debug)
00139         for key in ('jobClass', 'jobArgs'):
00140             if kw.has_key(key):
00141                 del kw[key]
00142         ThreadedServer.__init__(self, jobClass=Connection, jobArgs=(self,),
00143                                 **kw)


Member Function Documentation

Main loop. Call this after instantiating WSGIServer. SIGHUP, SIGINT,
SIGQUIT, SIGTERM cause it to cleanup and return. (If a SIGHUP
is caught, this method returns True. Returns False otherwise.)

Definition at line 144 of file scgi.py.

00144 
00145     def run(self):
00146         """
00147         Main loop. Call this after instantiating WSGIServer. SIGHUP, SIGINT,
00148         SIGQUIT, SIGTERM cause it to cleanup and return. (If a SIGHUP
00149         is caught, this method returns True. Returns False otherwise.)
00150         """
00151         self.logger.info('%s starting up', self.__class__.__name__)
00152 
00153         try:
00154             sock = self._setupSocket()
00155         except socket.error, e:
00156             self.logger.error('Failed to bind socket (%s), exiting', e[1])
00157             return False
00158 
00159         ret = ThreadedServer.run(self, sock)
00160 
00161         self._cleanupSocket(sock)
00162         self.shutdown()
00163 
00164         self.logger.info('%s shutting down%s', self.__class__.__name__,
00165                          self._hupReceived and ' (reload requested)' or '')
00166 
00167         return ret

Here is the call graph for this function:


The documentation for this class was generated from the following file: