summaryrefslogtreecommitdiff
path: root/paste/servers
diff options
context:
space:
mode:
authorianb <devnull@localhost>2005-05-14 06:10:38 +0000
committerianb <devnull@localhost>2005-05-14 06:10:38 +0000
commit9f06963d1e4efa62d7e70b34151094986ae5b2c1 (patch)
tree80ebf9bc56803280011ea27c92fe127bc38a6999 /paste/servers
parent9b267d3e23b5935b8be4fcea139186f570f6f23c (diff)
downloadpaste-9f06963d1e4efa62d7e70b34151094986ae5b2c1.tar.gz
Finished making servers pluggable
Diffstat (limited to 'paste/servers')
-rw-r--r--paste/servers/cgi/__init__.py1
-rw-r--r--paste/servers/cgi_server.py30
-rw-r--r--paste/servers/cgi_wsgi.py (renamed from paste/servers/cgi/cgiserver.py)0
-rw-r--r--paste/servers/console_server.py32
-rw-r--r--paste/servers/scgi/__init__.py1
-rw-r--r--paste/servers/scgi_server/__init__.py7
-rw-r--r--paste/servers/scgi_server/scgiserver.py (renamed from paste/servers/scgi/scgiserver.py)0
-rw-r--r--paste/servers/server_script_template.py19
-rw-r--r--paste/servers/wsgiutils_server.py (renamed from paste/servers/wsgiutils.py)6
9 files changed, 92 insertions, 4 deletions
diff --git a/paste/servers/cgi/__init__.py b/paste/servers/cgi/__init__.py
deleted file mode 100644
index 792d600..0000000
--- a/paste/servers/cgi/__init__.py
+++ /dev/null
@@ -1 +0,0 @@
-#
diff --git a/paste/servers/cgi_server.py b/paste/servers/cgi_server.py
new file mode 100644
index 0000000..7bf8ce3
--- /dev/null
+++ b/paste/servers/cgi_server.py
@@ -0,0 +1,30 @@
+import os
+import sys
+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
+
+ template_fn = os.path.join(os.path.dirname(__file__),
+ 'server_script_template.py')
+ 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.cgiserver import run_with_cgi"
+ print " run_with_cgi(app)"
diff --git a/paste/servers/cgi/cgiserver.py b/paste/servers/cgi_wsgi.py
index 83d257c..83d257c 100644
--- a/paste/servers/cgi/cgiserver.py
+++ b/paste/servers/cgi_wsgi.py
diff --git a/paste/servers/console_server.py b/paste/servers/console_server.py
new file mode 100644
index 0000000..92f4456
--- /dev/null
+++ b/paste/servers/console_server.py
@@ -0,0 +1,32 @@
+from paste import wsgilib
+
+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')
diff --git a/paste/servers/scgi/__init__.py b/paste/servers/scgi/__init__.py
deleted file mode 100644
index 792d600..0000000
--- a/paste/servers/scgi/__init__.py
+++ /dev/null
@@ -1 +0,0 @@
-#
diff --git a/paste/servers/scgi_server/__init__.py b/paste/servers/scgi_server/__init__.py
new file mode 100644
index 0000000..0ef4e56
--- /dev/null
+++ b/paste/servers/scgi_server/__init__.py
@@ -0,0 +1,7 @@
+from paste.util import thirdparty
+thirdparty.add_package('scgi')
+from scgiserver import serve_application
+
+def serve(conf, app):
+ prefix = conf.get('scgi_prefix', '/')
+ serve_application(app, prefix, port=int(conf.get('port', 4000)))
diff --git a/paste/servers/scgi/scgiserver.py b/paste/servers/scgi_server/scgiserver.py
index 15fbef2..15fbef2 100644
--- a/paste/servers/scgi/scgiserver.py
+++ b/paste/servers/scgi_server/scgiserver.py
diff --git a/paste/servers/server_script_template.py b/paste/servers/server_script_template.py
new file mode 100644
index 0000000..aa5c1cb
--- /dev/null
+++ b/paste/servers/server_script_template.py
@@ -0,0 +1,19 @@
+import os
+from paste import server
+from paste.pyconfig import Config
+from paste.configmiddleware import config_middleware
+from paste.webkit import wsgiwebkit
+
+conf = Config()
+conf.load_dict(server.default_ops, 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'])
+if conf.get('sys_path'):
+ server.update_sys_path(conf['sys_path'], conf['verbose'])
+
+app = wsgiwebkit.webkit(conf['publish_dir'], use_lint=conf.get('lint'))
+app = config_middleware(app, conf)
diff --git a/paste/servers/wsgiutils.py b/paste/servers/wsgiutils_server.py
index 2c63854..00ff182 100644
--- a/paste/servers/wsgiutils.py
+++ b/paste/servers/wsgiutils_server.py
@@ -1,6 +1,8 @@
+from paste.util import thirdparty
+thirdparty.add_package('wsgiutils')
+from wsgiutils import wsgiServer
+
def serve(conf, app):
- thirdparty.add_package('wsgiutils')
- from wsgiutils import wsgiServer
server = wsgiServer.WSGIServer(
(conf.get('host', 'localhost'),
int(conf.get('port', 8080))), {'': app})