/opt/alt/python37/lib/python3.7/site-packages/paste/util
NameSizeModeActions
looper/-0755rm
template/-0755rm
__pycache__/-0755rm
classinit.py18490644editdlrm
classinit.pyc19310644editdlrm
classinit.pyo19310644editdlrm
classinstance.py13730644editdlrm
classinstance.pyc23230644editdlrm
classinstance.pyo21610644editdlrm
converters.py8630644editdlrm
converters.pyc11740644editdlrm
converters.pyo11740644editdlrm
dateinterval.py24140644editdlrm
dateinterval.pyc31500644editdlrm
dateinterval.pyo31500644editdlrm
datetimeutil.py111700644editdlrm
datetimeutil.pyc102530644editdlrm
datetimeutil.pyo102530644editdlrm
doctest24.py994180644editdlrm
doctest24.pyc844030644editdlrm
doctest24.pyo841150644editdlrm
filemixin.py14310644editdlrm
filemixin.pyc20620644editdlrm
filemixin.pyo20620644editdlrm
finddata.py38410644editdlrm
finddata.pyc29560644editdlrm
finddata.pyo29560644editdlrm
findpackage.py7860644editdlrm
findpackage.pyc9140644editdlrm
findpackage.pyo9140644editdlrm
import_string.py31100644editdlrm
import_string.pyc33450644editdlrm
import_string.pyo33450644editdlrm
intset.py191310644editdlrm
intset.pyc195320644editdlrm
intset.pyo195320644editdlrm
ip4.py92710644editdlrm
ip4.pyc92430644editdlrm
ip4.pyo92430644editdlrm
killthread.py12290644editdlrm
killthread.pyc14310644editdlrm
killthread.pyo14310644editdlrm
looper.py.tmpta39690644editdlrm
mimeparse.py65920644editdlrm
mimeparse.pyc71580644editdlrm
mimeparse.pyo71580644editdlrm
multidict.py114090644editdlrm
multidict.pyc167200644editdlrm
multidict.pyo167200644editdlrm
PySourceColor.py858650644editdlrm
PySourceColor.pyc556160644editdlrm
PySourceColor.pyo556160644editdlrm
quoting.py24760644editdlrm
quoting.pyc30140644editdlrm
quoting.pyo30140644editdlrm
scgiserver.py56360644editdlrm
scgiserver.pyc61260644editdlrm
scgiserver.pyo60150644editdlrm
string24.py167430644editdlrm
string24.pyc186850644editdlrm
string24.pyo186850644editdlrm
template.py.tmpta242950644editdlrm
threadedprint.py82110644editdlrm
threadedprint.pyc103980644editdlrm
threadedprint.pyo90510644editdlrm
threadinglocal.py14840644editdlrm
threadinglocal.pyc20580644editdlrm
threadinglocal.pyo20580644editdlrm
UserDict24.py55160644editdlrm
UserDict24.pyc105130644editdlrm
UserDict24.pyo105130644editdlrm
__init__.py860644editdlrm
__init__.pyc2570644editdlrm
__init__.pyo2570644editdlrm
Edit: /opt/alt/python37/lib/python3.7/site-packages/paste/util/scgiserver.py (5636B)
""" SCGI-->WSGI application proxy, "SWAP". (Originally written by Titus Brown.) This lets an SCGI front-end like mod_scgi be used to execute WSGI application objects. To use it, subclass the SWAP class like so:: class TestAppHandler(swap.SWAP): def __init__(self, *args, **kwargs): self.prefix = '/canal' self.app_obj = TestAppClass swap.SWAP.__init__(self, *args, **kwargs) where 'TestAppClass' is the application object from WSGI and '/canal' is the prefix for what is served by the SCGI Web-server-side process. Then execute the SCGI handler "as usual" by doing something like this:: scgi_server.SCGIServer(TestAppHandler, port=4000).serve() and point mod_scgi (or whatever your SCGI front end is) at port 4000. Kudos to the WSGI folk for writing a nice PEP & the Quixote folk for writing a nice extensible SCGI server for Python! """ import sys import time from scgi import scgi_server def debug(msg): timestamp = time.strftime("%Y-%m-%d %H:%M:%S", time.localtime(time.time())) sys.stderr.write("[%s] %s\n" % (timestamp, msg)) class SWAP(scgi_server.SCGIHandler): """ SCGI->WSGI application proxy: let an SCGI server execute WSGI application objects. """ app_obj = None prefix = None def __init__(self, *args, **kwargs): assert self.app_obj, "must set app_obj" assert self.prefix is not None, "must set prefix" args = (self,) + args scgi_server.SCGIHandler.__init__(*args, **kwargs) def handle_connection(self, conn): """ Handle an individual connection. """ input = conn.makefile("r") output = conn.makefile("w") environ = self.read_env(input) environ['wsgi.input'] = input environ['wsgi.errors'] = sys.stderr environ['wsgi.version'] = (1, 0) environ['wsgi.multithread'] = False environ['wsgi.multiprocess'] = True environ['wsgi.run_once'] = False # dunno how SCGI does HTTPS signalling; can't test it myself... @CTB if environ.get('HTTPS','off') in ('on','1'): environ['wsgi.url_scheme'] = 'https' else: environ['wsgi.url_scheme'] = 'http' ## SCGI does some weird environ manglement. We need to set ## SCRIPT_NAME from 'prefix' and then set PATH_INFO from ## REQUEST_URI. prefix = self.prefix path = environ['REQUEST_URI'][len(prefix):].split('?', 1)[0] environ['SCRIPT_NAME'] = prefix environ['PATH_INFO'] = path headers_set = [] headers_sent = [] chunks = [] def write(data): chunks.append(data) def start_response(status, response_headers, exc_info=None): if exc_info: try: if headers_sent: # Re-raise original exception if headers sent raise exc_info[0], exc_info[1], exc_info[2] finally: exc_info = None # avoid dangling circular ref elif headers_set: raise AssertionError("Headers already set!") headers_set[:] = [status, response_headers] return write ### result = self.app_obj(environ, start_response) try: for data in result: chunks.append(data) # Before the first output, send the stored headers if not headers_set: # Error -- the app never called start_response status = '500 Server Error' response_headers = [('Content-type', 'text/html')] chunks = ["XXX start_response never called"] else: status, response_headers = headers_sent[:] = headers_set output.write('Status: %s\r\n' % status) for header in response_headers: output.write('%s: %s\r\n' % header) output.write('\r\n') for data in chunks: output.write(data) finally: if hasattr(result,'close'): result.close() # SCGI backends use connection closing to signal 'fini'. try: input.close() output.close() conn.close() except IOError, err: debug("IOError while closing connection ignored: %s" % err) def serve_application(application, prefix, port=None, host=None, max_children=None): """ Serve the specified WSGI application via SCGI proxy. ``application`` The WSGI application to serve. ``prefix`` The prefix for what is served by the SCGI Web-server-side process. ``port`` Optional port to bind the SCGI proxy to. Defaults to SCGIServer's default port value. ``host`` Optional host to bind the SCGI proxy to. Defaults to SCGIServer's default host value. ``host`` Optional maximum number of child processes the SCGIServer will spawn. Defaults to SCGIServer's default max_children value. """ class SCGIAppHandler(SWAP): def __init__ (self, *args, **kwargs): self.prefix = prefix self.app_obj = application SWAP.__init__(self, *args, **kwargs) kwargs = dict(handler_class=SCGIAppHandler) for kwarg in ('host', 'port', 'max_children'): if locals()[kwarg] is not None: kwargs[kwarg] = locals()[kwarg] scgi_server.SCGIServer(**kwargs).serve()