summaryrefslogtreecommitdiff
path: root/paste/servers
diff options
context:
space:
mode:
Diffstat (limited to 'paste/servers')
-rw-r--r--paste/servers/README.txt24
-rw-r--r--paste/servers/__init__.py1
-rw-r--r--paste/servers/ajp_fork_server.py12
-rw-r--r--paste/servers/ajp_threaded_server.py60
-rw-r--r--paste/servers/cgi_server.py65
-rw-r--r--paste/servers/cgi_wsgi.py113
-rw-r--r--paste/servers/console_server.py43
-rw-r--r--paste/servers/fastcgi_fork_server.py11
-rw-r--r--paste/servers/fastcgi_threaded_server.py48
-rw-r--r--paste/servers/scgi_flup_fork_server.py12
-rw-r--r--paste/servers/scgi_server/__init__.py22
-rw-r--r--paste/servers/scgi_server/scgiserver.py149
-rw-r--r--paste/servers/scgi_threaded_server.py42
-rw-r--r--paste/servers/server_script_template.py.txt16
-rw-r--r--paste/servers/wsgiutils_server.py24
15 files changed, 0 insertions, 642 deletions
diff --git a/paste/servers/README.txt b/paste/servers/README.txt
deleted file mode 100644
index 7b91d24..0000000
--- a/paste/servers/README.txt
+++ /dev/null
@@ -1,24 +0,0 @@
-This directory contains plugins for servers. Each plugin is
-identified by having "_server" on the end of its name. Plugins can be
-directories (Python packages), Python modules, or text (.txt) files.
-
-A text file must contain one (non-empty, non-comment) line, which is
-the name of a module that should be considered a server. E.g., you'd
-put "myapp.my_paste_server" in there, so that you could implement a
-server in your own package.
-
-Modules should have certain symbols (only 'serve' is required):
-
-serve(conf, app):
- Required; this serves the given application, using the given
- configuration options.
-options:
- A list of (option_name, option_help), describing the options this
- servers uses.
-description:
- A fairly short (2-3 line) description of this server.
-help:
- A longer help text.
-
-Note: if you have a package, __init__.py must contain these
-variables. \ No newline at end of file
diff --git a/paste/servers/__init__.py b/paste/servers/__init__.py
deleted file mode 100644
index 792d600..0000000
--- a/paste/servers/__init__.py
+++ /dev/null
@@ -1 +0,0 @@
-#
diff --git a/paste/servers/ajp_fork_server.py b/paste/servers/ajp_fork_server.py
deleted file mode 100644
index 469fce7..0000000
--- a/paste/servers/ajp_fork_server.py
+++ /dev/null
@@ -1,12 +0,0 @@
-from ajp_threaded_server import *
-
-def serve(conf, app):
- from flup.server.ajp_fork import WSGIServer
- return serve_server(conf, app, WSGIServer)
-
-description = """\
-An AJP (Apache Jarkarta Tomcat Connector) forking (multiprocess)
-server. For more about AJP see
-<http://jakarta.apache.org/tomcat/connectors-doc/>. This server is
-from flup <http://www.saddi.com/software/flup/>
-"""
diff --git a/paste/servers/ajp_threaded_server.py b/paste/servers/ajp_threaded_server.py
deleted file mode 100644
index 8bdedc7..0000000
--- a/paste/servers/ajp_threaded_server.py
+++ /dev/null
@@ -1,60 +0,0 @@
-from optparse import Option
-from paste.util import thirdparty
-thirdparty.add_package('flup')
-from paste import pyconfig
-
-def serve(conf, app):
- from flup.server.ajp import WSGIServer
- return serve_server(conf, app, WSGIServer)
-
-def serve_server(conf, app, server_class):
- root_url = conf.get('root_url', '')
- root_url = root_url and root_url.rstrip('/')
- server = server_class(
- app,
- scriptName=root_url,
- bindAddress=(conf.get('host', 'localhost'),
- int(conf.get('port', 8009))),
- allowedServers=pyconfig.make_list(conf.get('allowed_servers', None)))
- return server.run()
-
-options = [
- Option('--host',
- metavar="HOST",
- help='The host name to bind to (default localhost). Note, if binding to localhost, only local connections will be allowed.'),
- Option('--port',
- metavar="PORT",
- help='The port to bind to (default 8009).'),
- Option('--root-url',
- metavar="URL",
- help='The URL level to expect for incoming connections; if not set and this is not bound to /, then SCRIPT_NAME and PATH_INFO may be incorrect.'),
- Option('--allowed-servers',
- metavar="IP_LIST",
- help='A list of servers to allow connections from.'),
- ]
-
-description = """\
-An AJP (Apache Jarkarta Tomcat Connector) threaded server. For more
-about AJP see <http://jakarta.apache.org/tomcat/connectors-doc/>.
-This server is from flup: <http://www.saddi.com/software/flup/>.
-"""
-
-help = """\
-When configuring, you would set worker.properties to something like
-(for mod_jk):
-
- worker.list=foo
- worker.foo.port=8009
- worker.foo.host=localhost
- worker.foo.type=ajp13
-
-Example httpd.conf (for mod_jk):
-
- JkWorkersFile /path/to/workers.properties
- JkMount /* foo
-
-If your ajp application is not on the root, you SHOULD specify
-root_url so that SCRIPT_NAME and PATH_INFO are correct.
-"""
-
-# @@: TODO: handle the logging level, or integrate logging
diff --git a/paste/servers/cgi_server.py b/paste/servers/cgi_server.py
deleted file mode 100644
index bd402bf..0000000
--- a/paste/servers/cgi_server.py
+++ /dev/null
@@ -1,65 +0,0 @@
-import os
-import sys
-import commands
-from paste import server
-
-def serve(conf, app):
- replacements = {}
- replacements['default_config_fn'] = os.path.abspath(
- server.default_config_fn)
-
- # Ideally, other_conf should be any options that came from the
- # command-line.
- # @@: This assumes too much about the ordering of namespaces.
- other_conf = dict(conf.namespaces[-2])
- # Not a good idea to let 'verbose' through, but this doesn't really
- # stop any sourced configs from setting it either...
- if other_conf.has_key('verbose'):
- del other_conf['verbose']
- replacements['other_conf'] = other_conf
- replacements['extra_sys_path'] = find_extra_sys_path()
-
- template_fn = os.path.join(os.path.dirname(__file__),
- 'server_script_template.py.txt')
- template = open(template_fn).read()
- for name, value in replacements.items():
- template = template.replace('@@' + name + '@@', repr(value))
-
- print "#!%s" % sys.executable
- print template
- print "if __name__ == '__main__':"
- print " from paste.servers.cgi_wsgi import run_with_cgi"
- print " run_with_cgi(app, redirect_stdout=True)"
-
-description = """\
-A 'server' that creates a CGI script that you can use to invoke your
-application.
-"""
-
-help = """\
-Typically you would use this like:
-
- %prog --server=cgi > .../cgi-bin/myapp.cgi
- chmod +x .../cgi-bin/myapp.cgi
-"""
-
-def find_extra_sys_path():
- """
- Tries to find all the items on sys.path that wouldn't be there
- normally.
- """
- args = [sys.executable, "-c", "import sys; print sys.path"]
- old_keys = {}
- for key, value in os.environ.items():
- if key.startswith('PYTHON'):
- old_keys[key] = value
- del os.environ[key]
- result = commands.getoutput('%s -c "import sys; print sys.path"'
- % sys.executable)
- os.environ.update(old_keys)
- bare_sys_path = eval(result)
- extra = [path for path in sys.path
- if path not in bare_sys_path]
- return extra
-
-
diff --git a/paste/servers/cgi_wsgi.py b/paste/servers/cgi_wsgi.py
deleted file mode 100644
index 83d257c..0000000
--- a/paste/servers/cgi_wsgi.py
+++ /dev/null
@@ -1,113 +0,0 @@
-"""
-cgi WSGI server
-===============
-
-Usage
------
-
-The CGI script is the configuration and glue for this server.
-Typically you will write a CGI script like::
-
- #!/usr/bin/env python
- from paste.cgiserver import run_with_cgi
- # Assuming app is your WSGI application object...
- from myapplication import app
- run_with_cgi(app)
-
-"""
-
-import os, sys
-
-def run_with_cgi(application,
- use_cgitb=True,
- redirect_stdout=False):
- stdout = sys.stdout
-
- if use_cgitb:
- import cgitb
- cgitb.enable()
-
- environ = dict(os.environ)
- environ['wsgi.input'] = sys.stdin
- environ['wsgi.errors'] = sys.stderr
- environ['wsgi.version'] = (1, 0)
- environ['wsgi.multithread'] = False
- environ['wsgi.multiprocess'] = True
- environ['wsgi.run_once'] = True
-
- if os.environ.get('HTTPS', 'off').lower() in ('on', '1'):
- environ['wsgi.url_scheme'] = 'https'
- else:
- environ['wsgi.url_scheme'] = 'http'
-
- if redirect_stdout:
- sys.stdout = sys.stderr
-
- headers_set = []
- headers_sent = []
- result = None
-
- def write(data):
- assert headers_set, "write() before start_response()"
-
- if not headers_sent:
- # Before the first output, send the stored headers
- status, response_headers = headers_sent[:] = headers_set
-
- # See if Content-Length is given.
- found = False
- for name, value in response_headers:
- if name.lower() == 'content-length':
- found = True
- break
-
- # If not given, try to deduce it if the iterator implements
- # __len__ and is of length 1. (data will be result[0] in this
- # case.)
- if not found and result is not None:
- try:
- if len(result) == 1:
- response_headers.append(('Content-Length',
- str(len(data))))
- except:
- pass
-
- stdout.write('Status: %s\r\n' % status)
- for header in response_headers:
- stdout.write('%s: %s\r\n' % header)
- stdout.write('\r\n')
-
- stdout.write(data)
- stdout.flush()
-
- 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
- else:
- assert not headers_set, "Headers already set!"
-
- headers_set[:] = [status, response_headers]
- return write
-
- result = application(environ, start_response)
- try:
- for data in result:
- if data: # don't send headers until body appears
- write(data)
- if not headers_sent:
- write('') # send headers now if body was empty
- finally:
- if hasattr(result, 'close'):
- result.close()
-
-if __name__ == '__main__':
- def myapp(environ, start_response):
- start_response('200 OK', [('Content-Type', 'text/plain')])
- return ['Hello World!\n']
-
- run_with_cgi(myapp)
diff --git a/paste/servers/console_server.py b/paste/servers/console_server.py
deleted file mode 100644
index 02512a9..0000000
--- a/paste/servers/console_server.py
+++ /dev/null
@@ -1,43 +0,0 @@
-from paste import wsgilib
-from optparse import Option
-
-def serve(conf, app):
- url = conf.get('url', '/')
- query_string = ''
- if '?' in url:
- url, query_string = url.split('?', 1)
- quiet = conf.get('quiet', False)
- status, headers, content, errors = wsgilib.raw_interactive(
- app, url, QUERY_STRING=query_string)
- any_header = False
- if not quiet or int(status.split()[0]) != 200:
- print 'Status:', status
- any_header = True
- for header, value in headers:
- if quiet and (
- header.lower() in ('content-type', 'content-length')
- or (header.lower() == 'set-cookie'
- and value.startswith('_SID_'))):
- continue
- print '%s: %s' % (header, value)
- any_header = True
- if any_header:
- print
- if conf.get('compact', False):
- # Remove empty lines
- content = '\n'.join([l for l in content.splitlines()
- if l.strip()])
- print content
- if errors:
- sys.stderr.write('-'*25 + ' Errors ' + '-'*25 + '\n')
- sys.stderr.write(errors + '\n')
-
-description = """\
-Displays a single request to stdout
-"""
-
-options = [
- Option('--url',
- metavar='URL',
- help="The URL (not including domain or port!) to GET"),
- ]
diff --git a/paste/servers/fastcgi_fork_server.py b/paste/servers/fastcgi_fork_server.py
deleted file mode 100644
index 8d059af..0000000
--- a/paste/servers/fastcgi_fork_server.py
+++ /dev/null
@@ -1,11 +0,0 @@
-from fastcgi_threaded_server import *
-
-def serve(conf, app):
- from flup.server.fcgi_fork import WSGIServer
- return serve_server(conf, app, WSGIServer)
-
-description = """\
-A FastCGI forking (multiprocess) server. For more information on
-FastCGI see <http://www.fastcgi.com>. This server is from flup:
-<http://www.saddi.com/software/flup/>.
-"""
diff --git a/paste/servers/fastcgi_threaded_server.py b/paste/servers/fastcgi_threaded_server.py
deleted file mode 100644
index d8857f7..0000000
--- a/paste/servers/fastcgi_threaded_server.py
+++ /dev/null
@@ -1,48 +0,0 @@
-import os
-from optparse import Option
-from paste.util import thirdparty
-thirdparty.add_package('flup')
-from paste import pyconfig
-
-def serve(conf, app):
- from flup.server.fcgi import WSGIServer
- return serve_server(conf, app, WSGIServer)
-
-def serve_server(conf, app, server_class):
- if conf.get('host'):
- if not conf.get('port'):
- raise ValueError(
- "There is no default port for FastCGI; if you give 'host' you must provide 'port'")
- address = (conf['host'], conf['port'])
- elif conf.get('socket'):
- address = conf['socket']
- else:
- address = os.path.join(conf.get('root_path', ''), 'fcgi_sock')
- # @@: Right now there's no automatic socket, and the parent server
- # can't start up this server in any way.
- server = server_class(
- app,
- bindAddress=address,
- multiplexed=pyconfig.make_bool(conf.get('multiplexed', False)))
- return server.run()
-
-options = [
- Option('--socket',
- metavar="FILENAME",
- help='The filename of a socket to listen to for connections. Default is fcgi_sock in the current directory.'),
- Option('--host',
- metavar="HOST",
- help='The host to bind to when listening for connections over the network. You must also provide port if you provide host.'),
- Option('--port',
- metavar="PORT",
- help='The port to bind to.'),
- Option('--multiplex',
- metavar="true/false",
- help='Option to multiplex connections (default: false).'),
- ]
-
-description = """\
-A FastCGI threaded server. For more information on FastCGI see
-<http://www.fastcgi.com>. This server is from flup:
-<http://www.saddi.com/software/flup/>.
-"""
diff --git a/paste/servers/scgi_flup_fork_server.py b/paste/servers/scgi_flup_fork_server.py
deleted file mode 100644
index 67d5e1e..0000000
--- a/paste/servers/scgi_flup_fork_server.py
+++ /dev/null
@@ -1,12 +0,0 @@
-from scgi_threaded_server import *
-
-def serve(conf, app):
- from flup.server.scgi_fork import WSGIServer
- return serve_server(conf, app, WSGIServer)
-
-description = """\
-A SCGI forking (multiprocess) server. SCGI is a FastCGI alternative
-(see <http://www.mems-exchange.org/software/scgi/> for more). This
-server (unlike the 'scgi' server, which is also forking) is from flup:
-<http://www.saddi.com/software/flup/>.
-"""
diff --git a/paste/servers/scgi_server/__init__.py b/paste/servers/scgi_server/__init__.py
deleted file mode 100644
index 9f56609..0000000
--- a/paste/servers/scgi_server/__init__.py
+++ /dev/null
@@ -1,22 +0,0 @@
-from optparse import Option
-from paste.util import thirdparty
-thirdparty.add_package('scgi')
-from scgiserver import serve_application
-
-def serve(conf, app):
- prefix = conf.get('root_url', '').rstrip('/')
- serve_application(app, prefix, port=int(conf.get('port', 4000)))
-
-options = [
- Option('--port',
- metavar="PORT",
- help='Port to serve on (default 4000).'),
- Option('--root-url',
- metavar="URL",
- help='The URL level to expect for incoming connections; if not set and this is not bound to /, then SCRIPT_NAME and PATH_INFO may be incorrect.'),
- ]
-
-description = """\
-A pre-forking SCGI server. SCGI is a FastCGI alternative
-(see <http://www.mems-exchange.org/software/scgi/> for more).
-"""
diff --git a/paste/servers/scgi_server/scgiserver.py b/paste/servers/scgi_server/scgiserver.py
deleted file mode 100644
index fabeeda..0000000
--- a/paste/servers/scgi_server/scgiserver.py
+++ /dev/null
@@ -1,149 +0,0 @@
-#! /usr/bin/env python
-"""
-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
-import os
-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, "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):]
- path = path.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):
- class SCGIAppHandler(SWAP):
- def __init__ (self, *args, **kwargs):
- self.prefix = prefix
- self.app_obj = application
- SWAP.__init__(self, *args, **kwargs)
-
- scgi_server.SCGIServer(SCGIAppHandler, port=port).serve()
diff --git a/paste/servers/scgi_threaded_server.py b/paste/servers/scgi_threaded_server.py
deleted file mode 100644
index a023e7f..0000000
--- a/paste/servers/scgi_threaded_server.py
+++ /dev/null
@@ -1,42 +0,0 @@
-from paste.util import thirdparty
-thirdparty.add_package('flup')
-from paste import pyconfig
-from optparse import Option
-
-def serve(conf, app):
- from flup.server.scgi import WSGIServer
- return serve_server(conf, app, WSGIServer)
-
-def serve_server(conf, app, server_class):
- root_url = conf.get('root_url', '')
- root_url = root_url and root_url.rstrip('/')
- server = server_class(
- app,
- bindAddress=(conf.get('host', 'localhost'),
- int(conf.get('port', '4000'))),
- scriptName=root_url,
- allowedServers=pyconfig.make_list(conf.get('allowed_servers', None)))
- return server.run()
-
-options = [
- Option('--host',
- metavar='HOST',
- help='The host name to bind to (default localhost). Note, if binding to localhost, only local connections will be allowed.'),
- Option('--port',
- metavar="PORT",
- help='The port to bind to (default 4000).'),
- Option('--root-url',
- metavar="URL",
- help='The URL level to expect for incoming connections; if not set and this is not bound to /, then SCRIPT_NAME and PATH_INFO may be incorrect.'),
- Option('--allowed-servers',
- metavar="URL_LIST",
- help='A list of servers to allow connections from.'),
- ]
-
-description = """\
-A SCGI multithreaded server. SCGI is a FastCGI alternative (see
-<http://www.mems-exchange.org/software/scgi/> for more). This server
-is from flup: <http://www.saddi.com/software/flup/>.
-"""
-
-# @@: TODO: handle the logging level, or integrate logging
diff --git a/paste/servers/server_script_template.py.txt b/paste/servers/server_script_template.py.txt
deleted file mode 100644
index e1e7e86..0000000
--- a/paste/servers/server_script_template.py.txt
+++ /dev/null
@@ -1,16 +0,0 @@
-import os
-import sys
-sys.path.extend(@@extra_sys_path@@)
-from paste import server
-from paste.pyconfig import Config
-
-conf = Config(with_default=True)
-conf.load_dict(@@other_conf@@)
-server.load_conf(conf, @@default_config_fn@@)
-if not conf.get('no_server_conf') and os.path.exists('server.conf'):
- server.load_conf(conf, 'server.conf')
-if conf.get('config_file'):
- server.load_conf(conf, conf['config_file'])
-conf.update_sys_path()
-
-app = server.make_app(conf)
diff --git a/paste/servers/wsgiutils_server.py b/paste/servers/wsgiutils_server.py
deleted file mode 100644
index ce501f4..0000000
--- a/paste/servers/wsgiutils_server.py
+++ /dev/null
@@ -1,24 +0,0 @@
-from optparse import Option
-from paste.util import thirdparty
-thirdparty.add_package('wsgiutils')
-from wsgiutils import wsgiServer
-
-def serve(conf, app):
- server = wsgiServer.WSGIServer(
- (conf.get('host', 'localhost'),
- int(conf.get('port', 8080))), {'': app})
- server.serve_forever()
-
-description = """\
-WSGIUtils <http://www.owlfish.com/software/wsgiutils/> is a small
-threaded server using Python's standard SimpleHTTPServer.
-"""
-
-options = [
- Option('--port',
- metavar="PORT",
- help='Port to serve on (default: 8080)'),
- Option('--host',
- metavar="HOST",
- help='Host to serve from (default: localhost, which is only accessible from the local computer; use 0.0.0.0 to make your application public)'),
- ]