Back to index

moin  1.9.0~rc2
Public Member Functions | Public Attributes | Static Public Attributes
MoinMoin.web.flup_frontend.AJPFrontEnd Class Reference
Inheritance diagram for MoinMoin.web.flup_frontend.AJPFrontEnd:
Inheritance graph
[legend]
Collaboration diagram for MoinMoin.web.flup_frontend.AJPFrontEnd:
Collaboration graph
[legend]

List of all members.

Public Member Functions

def add_options
def run_server
def run

Public Attributes

 debug
 parser

Static Public Attributes

dictionary server_types

Detailed Description

Definition at line 144 of file flup_frontend.py.


Member Function Documentation

Reimplemented from MoinMoin.web.frontend.ServerFrontEnd.

Definition at line 47 of file flup_frontend.py.

00047 
00048         def add_options(self):
00049             super(FlupFrontEnd, self).add_options()
00050             parser = self.parser
00051             parser.add_option("--min-spare", dest="min_spare", type="int", metavar='MIN',
00052                               help=("Minimum spare threads/processes (when "
00053                                     "using threaded or forking servers)."))
00054             parser.add_option("--max-spare", dest="max_spare", type="int", metavar='MAX',
00055                               help=("Maximum spare threads/processes (when "
00056                                     "using threaded or forking servers)."))
00057             parser.add_option("--max-childs", dest="max_childs", type="int", metavar='CHILDS',
00058                               help=("Hard upper limit on threads/processes "
00059                                     "(when using threaded or forking servers)."))
00060             parser.add_option("-t", "--type", dest="server_type", metavar='TYPE',
00061                               help=("Type of server to use, e.g. single/threaded"
00062                                     "/forking. Defaults to 'single' when not "
00063                                     "bound to a socket and to 'threaded' when it is"))

def MoinMoin.web.frontend.FrontEnd.run (   self,
  args = None 
) [inherited]

Definition at line 32 of file frontend.py.

00032 
00033     def run(self, args=None):
00034         options, args = self.parser.parse_args(args)
00035         logging.debug('Options: %r', options)
00036 
00037         application = make_application(shared=options.htdocs)
00038 
00039         try:
00040             self.run_server(application, options)
00041         except SystemExit, err:
00042             # the flup CGIRequest uses sys.exit(0) to terminate
00043             if err.code: # log a non-zero exit status (0 means no error)
00044                 logging.exception('A SystemExit(%d) exception occurred.' % err.code)
00045             raise # exit now with this exit status
00046         except:
00047             logging.exception('An exception occurred while running %s' % self.__class__.__name__)

Here is the call graph for this function:

Here is the caller graph for this function:

def MoinMoin.web.flup_frontend.FlupFrontEnd.run_server (   self,
  application,
  options 
) [inherited]

Reimplemented in MoinMoin.web.flup_frontend.CGIFrontEnd.

Definition at line 64 of file flup_frontend.py.

00064 
00065         def run_server(self, application, options):
00066             server_type = options.server_type
00067 
00068             if not server_type:
00069                 if 'single' in self.server_types:
00070                     server_type = (options.port and 'threaded') or 'single'
00071                 else:
00072                     server_type = 'threaded'
00073 
00074             if server_type not in self.server_types:
00075                 raise TypeError("Unknown server type '%s'" % options.server_type)
00076 
00077             multi = server_type in ('threaded', 'forking')
00078 
00079             mod = self.server_types[server_type]
00080             mod = __import__(mod, globals(), locals(), ['WSGIServer'])
00081             WSGIServerWrapped = mod.WSGIServer
00082 
00083             class WSGIServer(WSGIServerWrapped):
00084                 def __init__(self, application, environ=None,
00085                              multithreaded=True, multiprocess=False,
00086                              bindAddress=None, umask=None, multiplexed=False,
00087                              debug="off", roles=(FCGI_RESPONDER, )):
00088                     WSGIServerWrapped.__init__(self, application, environ=environ,
00089                                                multithreaded=multithreaded, multiprocess=multiprocess,
00090                                                bindAddress=bindAddress, umask=umask, multiplexed=multiplexed,
00091                                                debug=debug, roles=roles)
00092 
00093                 def error(self, req):
00094                     """ Override the default handler, so it implements debug=web/external/off. """
00095                     if self.debug == 'external':
00096                         raise
00097                     elif self.debug == 'web':
00098                         import cgitb
00099                         req.stdout.write('Content-Type: text/html\r\n\r\n' +
00100                                          cgitb.html(sys.exc_info()))
00101                     else: # 'off'
00102                         errorpage = """<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN">
00103 <html><head>
00104 <title>Unhandled Exception</title>
00105 </head><body>
00106 <h1>Unhandled Exception</h1>
00107 <p>An unhandled exception was thrown by the application.</p>
00108 </body></html>
00109 """
00110                         req.stdout.write('Content-Type: text/html\r\n\r\n' + errorpage)
00111 
00112 
00113             kwargs = {}
00114 
00115             kwargs['debug'] = options.debug or os.environ.get('MOIN_DEBUGGER', 'off')
00116 
00117             if options.port:
00118                 kwargs['bindAddress'] = (options.interface, options.port)
00119             elif options.interface and (
00120                  options.interface.startswith('/') or options.interface.startswith('./')):
00121                 kwargs['bindAddress'] = options.interface
00122 
00123             if options.min_spare and multi:
00124                 kwargs['minSpare'] = options.min_spare
00125             if options.max_spare and multi:
00126                 kwargs['maxSpare'] = options.max_spare
00127             if options.max_childs and multi:
00128                 if server_type == 'threaded':
00129                     kwargs['maxThreads'] = options.max_childs
00130                 else:
00131                     kwargs['maxChildren'] = options.max_childs
00132             logging.debug("WSGIServer(%r, %r)" % (application, kwargs))
00133             return WSGIServer(application, **kwargs).run()
00134 
    class CGIFrontEnd(FlupFrontEnd):

Here is the call graph for this function:

Here is the caller graph for this function:


Member Data Documentation

Definition at line 94 of file flup_frontend.py.

Definition at line 17 of file frontend.py.

Initial value:
{'threaded': 'flup.server.ajp',
                        'forking': 'flup.server.ajp_fork'}

Definition at line 145 of file flup_frontend.py.


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