Django

Code

Changeset 4902

Show
Ignore:
Timestamp:
04/01/07 02:30:27 (1 year ago)
Author:
mtredinnick
Message:

Added support for SCGI and AJP. This is a piece that was missed in [4897]. Refs
#3047.

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • django/trunk/django/core/servers/fastcgi.py

    r4265 r4902  
    11""" 
    2 FastCGI server that implements the WSGI protocol. 
     2FastCGI (or SCGI, or AJP1.3 ...) server that implements the WSGI protocol. 
    33 
    44Uses the flup python package: http://www.saddi.com/software/flup/ 
     
    1919 
    2020FASTCGI_HELP = r"""runfcgi: 
    21   Run this project as a fastcgi application. To do this, the 
    22   flup package from http://www.saddi.com/software/flup/ is 
    23   required. 
     21  Run this project as a fastcgi (or some other protocol supported 
     22  by flup) application. To do this, the flup package from 
     23  http://www.saddi.com/software/flup/ is required. 
    2424 
    2525Usage: 
     
    2828 
    2929Optional Fcgi settings: (setting=value) 
     30  protocol=PROTOCOL    fcgi, scgi, ajp, ... (default fcgi) 
    3031  host=HOSTNAME        hostname to listen on.. 
    3132  port=PORTNUM         port to listen on. 
     
    4647    $ manage.py runfcgi method=threaded 
    4748 
    48   Run a fastcgi server on a TCP host/port 
    49     $ manage.py runfcgi method=prefork host=127.0.0.1 port=8025 
     49  Run a scgi server on a TCP host/port 
     50    $ manage.py runfcgi protocol=scgi method=prefork host=127.0.0.1 port=8025 
    5051 
    5152  Run a fastcgi server on a UNIX domain socket (posix platforms only) 
     
    5960 
    6061FASTCGI_OPTIONS = { 
     62    'protocol': 'fcgi', 
    6163    'host': None, 
    6264    'port': None, 
     
    101103        return False 
    102104 
     105    flup_module = 'server.' + options['protocol'] 
     106 
    103107    if options['method'] in ('prefork', 'fork'): 
    104         from flup.server.fcgi_fork import WSGIServer 
    105108        wsgi_opts = { 
    106109            'maxSpare': int(options["maxspare"]), 
     
    109112            'maxRequests': int(options["maxrequests"]),  
    110113        } 
     114        flup_module += '_fork' 
    111115    elif options['method'] in ('thread', 'threaded'): 
    112         from flup.server.fcgi import WSGIServer 
    113116        wsgi_opts = { 
    114117            'maxSpare': int(options["maxspare"]), 
     
    120123 
    121124    wsgi_opts['debug'] = False # Turn off flup tracebacks 
     125 
     126    try: 
     127        WSGIServer = getattr(__import__('flup.' + flup_module, '', '', flup_module), 'WSGIServer') 
     128    except: 
     129        print "Can't import flup." + flup_module 
     130        return False 
    122131 
    123132    # Prep up and go