changeset 4275:50d37349a9aa

Remove unused request/server code
author Florian Krupicka <florian.krupicka@googlemail.com>
date Thu, 07 Aug 2008 00:09:03 +0200
parents ba0daaf24d63
children 95decb0aeadd
files MoinMoin/request/request_cgi.py MoinMoin/request/request_cli.py MoinMoin/request/request_standalone.py MoinMoin/server/server_cgi.py
diffstat 4 files changed, 0 insertions(+), 348 deletions(-) [+]
line wrap: on
line diff
--- a/MoinMoin/request/request_cgi.py	Thu Aug 07 00:02:02 2008 +0200
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,73 +0,0 @@
-# -*- coding: iso-8859-1 -*-
-"""
-    MoinMoin - CGI Request Implementation for std. CGI web servers
-    like Apache or IIS or others.
-
-    @copyright: 2001-2003 by Juergen Hermann <jh@web.de>,
-                2003-2006 MoinMoin:ThomasWaldmann
-    @license: GNU GPL, see COPYING for details.
-"""
-import sys, os, cgi
-
-from MoinMoin import log
-logging = log.getLogger(__name__)
-
-from MoinMoin.request import RequestBase, RemoteClosedConnection
-
-class Request(RequestBase):
-    """ specialized on CGI requests """
-
-    def __init__(self, properties={}):
-        try:
-            # force input/output to binary
-            if sys.platform == "win32":
-                import msvcrt
-                msvcrt.setmode(sys.stdin.fileno(), os.O_BINARY)
-                msvcrt.setmode(sys.stdout.fileno(), os.O_BINARY)
-
-            self._setup_vars_from_std_env(os.environ)
-            RequestBase.__init__(self, properties)
-
-        except Exception, err:
-            self.fail(err)
-
-    def _setup_args_from_cgi_form(self):
-        """ Override to create cgi form """
-        form = cgi.FieldStorage(keep_blank_values=1)
-        return RequestBase._setup_args_from_cgi_form(self, form)
-
-    def read(self, n):
-        """ Read from input stream. """
-        if n is None:
-            logging.warning("calling request.read(None) might block")
-            return sys.stdin.read()
-        else:
-            return sys.stdin.read(n)
-
-    def write(self, *data):
-        """ Write to output stream. """
-        data = self.encode(data)
-        try:
-            sys.stdout.write(data)
-        except Exception:
-            raise RemoteClosedConnection()
-
-    def flush(self):
-        sys.stdout.flush()
-
-    def finish(self):
-        RequestBase.finish(self)
-        # flush the output, ignore errors caused by the user closing the socket
-        try:
-            sys.stdout.flush()
-        except IOError, ex:
-            import errno
-            if ex.errno != errno.EPIPE:
-                raise
-
-    def _emit_http_headers(self, headers):
-        """ private method to send out preprocessed list of HTTP headers """
-        for header in headers:
-            self.write("%s\r\n" % header)
-        self.write("\r\n")
-
--- a/MoinMoin/request/request_cli.py	Thu Aug 07 00:02:02 2008 +0200
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,104 +0,0 @@
-# -*- coding: iso-8859-1 -*-
-"""
-    MoinMoin - CLI Request Implementation for commandline usage.
-
-    @copyright: 2001-2003 Juergen Hermann <jh@web.de>,
-                2003-2006 MoinMoin:ThomasWaldmann
-    @license: GNU GPL, see COPYING for details.
-"""
-import sys
-
-from MoinMoin import log
-logging = log.getLogger(__name__)
-
-from MoinMoin.request import RequestBase, RemoteClosedConnection
-
-class Request(RequestBase):
-    """ specialized on command line interface and script requests """
-
-    def __init__(self, url='CLI', pagename='', properties={}):
-        self.saved_cookie = ''
-        self.path_info = '/' + pagename
-        self.query_string = ''
-        self.remote_addr = '127.0.0.1'
-        self.is_ssl = 0
-        self.http_user_agent = 'CLI/Script'
-        self.url = url
-        self.request_method = 'GET'
-        self.request_uri = '/' + pagename # TODO check if /pagename works as URI for CLI usage
-        self.http_host = 'localhost'
-        self.http_referer = ''
-        self.script_name = '.'
-        self.content_length = None
-        self.if_modified_since = None
-        self.if_none_match = None
-        RequestBase.__init__(self, properties)
-        self.cfg.caching_formats = [] # don't spoil the cache
-        self.initTheme() # usually request.run() does this, but we don't use it
-
-    def _setup_args_from_cgi_form(self):
-        """ Override to create cli form """
-        #form = cgi.FieldStorage()
-        #return RequestBase._setup_args_from_cgi_form(self, form)
-        return {}
-
-    def read(self, n):
-        """ Read from input stream. """
-        if n is None:
-            logging.warning("calling request.read(None) might block")
-            return sys.stdin.read()
-        else:
-            return sys.stdin.read(n)
-
-    def write(self, *data):
-        """ Write to output stream. """
-        data = self.encode(data)
-        try:
-            sys.stdout.write(data)
-        except IOError:
-            raise RemoteClosedConnection()
-
-    def flush(self):
-        sys.stdout.flush()
-
-    def finish(self):
-        RequestBase.finish(self)
-        # flush the output, ignore errors caused by the user closing the socket
-        try:
-            sys.stdout.flush()
-        except IOError, ex:
-            import errno
-            if ex.errno != errno.EPIPE:
-                raise
-
-    def isForbidden(self):
-        """ Nothing is forbidden """
-        return 0
-
-    # Accessors --------------------------------------------------------
-
-    def getQualifiedURL(self, uri=None):
-        """ Return a full URL starting with schema and host
-
-        TODO: does this create correct pages when you render wiki pages
-              within a cli request?!
-        """
-        return uri
-
-    # Headers ----------------------------------------------------------
-
-    def setHttpHeader(self, header):
-        pass
-
-    def _emit_http_headers(self, headers):
-        """ private method to send out preprocessed list of HTTP headers """
-        pass
-
-    def http_redirect(self, url):
-        """ Redirect to a fully qualified, or server-rooted URL
-
-        TODO: Does this work for rendering redirect pages?
-        """
-        raise Exception("Redirect not supported for command line tools!")
-
-
--- a/MoinMoin/request/request_standalone.py	Thu Aug 07 00:02:02 2008 +0200
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,108 +0,0 @@
-# -*- coding: iso-8859-1 -*-
-"""
-    MoinMoin - Standalone Moin Server Request Implementation
-
-    @copyright: 2001-2003 Juergen Hermann <jh@web.de>,
-                2003-2006 MoinMoin:ThomasWaldmann
-    @license: GNU GPL, see COPYING for details.
-"""
-import cgi
-
-from MoinMoin import log
-logging = log.getLogger(__name__)
-
-from MoinMoin.request import RequestBase, RemoteClosedConnection
-
-class Request(RequestBase):
-    """ specialized on StandAlone Server (MoinMoin.server.server_standalone) requests """
-    script_name = ''
-
-    def __init__(self, sa, properties={}):
-        """
-        @param sa: stand alone server object
-        @param properties: ...
-        """
-        try:
-            self.sareq = sa
-            self.wfile = sa.wfile
-            self.rfile = sa.rfile
-            self.headers = sa.headers
-            self.is_ssl = 0
-
-            # Copy headers
-            self.http_accept_language = (sa.headers.getheader('accept-language')
-                                         or self.http_accept_language)
-            self.http_user_agent = sa.headers.getheader('user-agent', '')
-            try:
-                self.content_length = int(sa.headers.getheader('content-length'))
-            except (TypeError, ValueError):
-                self.content_length = None
-            co = [c for c in sa.headers.getheaders('cookie') if c]
-            self.saved_cookie = ', '.join(co) or ''
-            self.if_modified_since = sa.headers.getheader('if-modified-since')
-            self.if_none_match = sa.headers.getheader('if-none-match')
-
-            # Copy rest from standalone request
-            self.server_name = sa.server.server_name
-            self.server_port = str(sa.server.server_port)
-            self.request_method = sa.command
-            self.request_uri = sa.path
-            self.remote_addr = sa.client_address[0]
-
-            # Values that need more work
-            self.path_info, self.query_string = self.splitURI(sa.path)
-            self.setHttpReferer(sa.headers.getheader('referer'))
-            self.setHost(sa.headers.getheader('host'))
-            self.setURL(sa.headers)
-
-            ##self.debugEnvironment(sa.headers)
-
-            RequestBase.__init__(self, properties)
-
-        except Exception, err:
-            self.fail(err)
-
-    def _setup_args_from_cgi_form(self):
-        """ Override to create standalone form """
-        form = cgi.FieldStorage(self.rfile, headers=self.headers, environ={'REQUEST_METHOD': 'POST'},
-                                keep_blank_values=1)
-        return RequestBase._setup_args_from_cgi_form(self, form)
-
-    def read(self, n):
-        """ Read from input stream """
-        if n is None:
-            logging.warning("calling request.read(None) might block")
-            return self.rfile.read()
-        else:
-            return self.rfile.read(n)
-
-    def write(self, *data):
-        """ Write to output stream. """
-        data = self.encode(data)
-        try:
-            self.wfile.write(data)
-        except Exception:
-            raise RemoteClosedConnection()
-
-    def flush(self):
-        self.wfile.flush()
-
-    def finish(self):
-        RequestBase.finish(self)
-        self.wfile.flush()
-
-    # Headers ----------------------------------------------------------
-
-    def _emit_http_headers(self, headers):
-        """ private method to send out preprocessed list of HTTP headers """
-        st_header, other_headers = headers[0], headers[1:]
-        status = st_header.split(':', 1)[1].lstrip()
-        status_code, status_msg = status.split(' ', 1)
-        status_code = int(status_code)
-        self.sareq.send_response(status_code, status_msg)
-        for header in other_headers:
-            key, value = header.split(':', 1)
-            value = value.lstrip()
-            self.sareq.send_header(key, value)
-        self.sareq.end_headers()
-
--- a/MoinMoin/server/server_cgi.py	Thu Aug 07 00:02:02 2008 +0200
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,63 +0,0 @@
-# -*- coding: iso-8859-1 -*-
-"""
-    MoinMoin - CGI pseudo Server
-
-    This is not really a server, it is just so that CGI stuff (the real
-    server is likely Apache or IIS or some other std. CGI server) looks
-    similar to what we have for Twisted and standalone server.
-
-    Minimal usage:
-
-        from MoinMoin.server.server_cgi import CgiConfig, run
-
-        class Config(CgiConfig):
-            pass
-
-        run(Config)
-
-    See more options in CgiConfig class.
-
-    @copyright: 2006 MoinMoin:ThomasWaldmann
-    @license: GNU GPL, see COPYING for details.
-"""
-
-from MoinMoin.server import Config
-from MoinMoin.request import request_cgi
-
-# Server globals
-config = None
-
-# ------------------------------------------------------------------------
-# Public interface
-
-class CgiConfig(Config):
-    """ CGI default config """
-    name = 'moin'
-    properties = {}
-
-    # Development options
-    hotshotProfile = None # e.g. "moin.prof"
-
-
-def run(configClass):
-    """ Create and run a Cgi Request
-
-    See CgiConfig for available options
-
-    @param configClass: config class
-    """
-
-    config = configClass()
-
-    if config.hotshotProfile:
-        import hotshot
-        config.hotshotProfile = hotshot.Profile(config.hotshotProfile)
-        config.hotshotProfile.start()
-
-    request = request_cgi.Request(properties=config.properties)
-    request.run()
-
-    if config.hotshotProfile:
-        config.hotshotProfile.close()
-
-