Esempio n. 1
0
    def setUpServer(self):
        """Create a ZServer server instance and save it in self.zserver
        """
        from ZServer import zhttp_server, zhttp_handler, logger
        from StringIO import StringIO

        log = self.log
        if log is None:
            log = StringIO()

        zopeLog = logger.file_logger(log)

        server = zhttp_server(
            ip=self.host,
            port=self.port,
            resolver=None,
            logger_object=zopeLog,
        )

        # If we dynamically set the host/port, we want to reset it to localhost
        # Otherwise this will depend on, for example, the local network setup
        if self.host in (
                '',
                '0.0.0.0',
                '127.0.0.1',
        ):
            server.server_name = 'localhost'
        # Refresh the hostname and port in case we dynamically picked them
        self['host'] = self.host = server.server_name
        self['port'] = self.port = server.server_port

        zhttpHandler = zhttp_handler(module='Zope2', uri_base='')
        server.install_handler(zhttpHandler)

        self.zserver = server
Esempio n. 2
0
    def setUpServer(self):
        """Create a ZServer server instance and save it in self.zserver
        """
        from ZServer import zhttp_server, zhttp_handler, logger
        from StringIO import StringIO

        log = self.log
        if log is None:
            log = StringIO()

        zopeLog = logger.file_logger(log)

        server = zhttp_server(
            ip=self.host,
            port=self.port,
            resolver=None,
            logger_object=zopeLog,
        )

        # If we dynamically set the host/port, we want to reset it to localhost
        # Otherwise this will depend on, for example, the local network setup
        if self.host in ('', '0.0.0.0', '127.0.0.1', ):
            server.server_name = 'localhost'
        # Refresh the hostname and port in case we dynamically picked them
        self['host'] = self.host = server.server_name
        self['port'] = self.port = server.server_port

        zhttpHandler = zhttp_handler(module='Zope2', uri_base='')
        server.install_handler(zhttpHandler)

        self.zserver = server
Esempio n. 3
0
def zserverRunner(host, port, log=None):
    '''Runs an HTTP ZServer on host:port.'''
    from ZServer import logger, asyncore
    from ZServer import zhttp_server, zhttp_handler
    if log is None: log = dummyLOG
    lg = logger.file_logger(log)
    hs = zhttp_server(ip=host, port=port, resolver=None, logger_object=lg)
    zh = zhttp_handler(module='Zope2', uri_base='')
    hs.install_handler(zh)
    asyncore.loop()
Esempio n. 4
0
def zserverRunner(host, port, log=None):
    '''Runs an HTTP ZServer on host:port.'''
    from ZServer import logger, asyncore
    from ZServer import zhttp_server, zhttp_handler
    if log is None: log = dummyLOG
    lg = logger.file_logger(log)
    hs = zhttp_server(ip=host, port=port, resolver=None, logger_object=lg)
    zh = zhttp_handler(module='Zope2', uri_base='')
    hs.install_handler(zh)
    asyncore.loop()
Esempio n. 5
0
    def setUpServer(self):
        """Create a ZServer server instance and save it in self.zserver
        """

        from ZServer import zhttp_server, zhttp_handler, logger
        from StringIO import StringIO

        log = self.log
        if log is None:
            log = StringIO()

        zopeLog = logger.file_logger(log)

        server = zhttp_server(ip=self.host, port=self.port, resolver=None, logger_object=zopeLog)
        zhttpHandler = zhttp_handler(module='Zope2', uri_base='')
        server.install_handler(zhttpHandler)

        self.zserver = server
Esempio n. 6
0
    def setUpServer(self):
        """Create a ZServer server instance and save it in self.zserver
        """

        from ZServer import zhttp_server, zhttp_handler, logger
        from StringIO import StringIO

        log = self.log
        if log is None:
            log = StringIO()

        zopeLog = logger.file_logger(log)

        server = zhttp_server(ip=self.host,
                              port=self.port,
                              resolver=None,
                              logger_object=zopeLog)
        zhttpHandler = zhttp_handler(module='Zope2', uri_base='')
        server.install_handler(zhttpHandler)

        self.zserver = server
    def setUpZServerThread(self):
        """Create a ZServer server instance and its thread

        Save them, respectively, in self.zserver and self.thread
        """

        from ZServer import zhttp_server, zhttp_handler, logger
        from cStringIO import StringIO

        zlog = logger.file_logger(StringIO())

        zserver = zhttp_server(ip=self.host,
                               port=self.port, 
                               resolver=None,
                               logger_object=zlog)
        zhandler = zhttp_handler(module=bobo_app_name, uri_base='')
        zserver.install_handler(zhandler)

        self.zserver = zserver
        name = self.__class__.__name__
        self.zthread = ZServerThread(name="%s server" % name)
        self.zthread.start()
            raise port_err % {'port':port,
                              'socktype':'TCP',
                              'protocol':'HTTP',
                              'switch':'-w'}
        raise
    # Handler for a published module. zhttp_handler takes 3 arguments:
    # The name of the module to publish, and optionally the URI base
    # which is basically the SCRIPT_NAME, and optionally a dictionary
    # with CGI environment variables which override default
    # settings. The URI base setting is useful when you want to
    # publish more than one module with the same HTTP server. The CGI
    # environment setting is useful when you want to proxy requests
    # from another web server to ZServer, and would like the CGI
    # environment to reflect the CGI environment of the other web
    # server.
    zh = zhttp_handler('Zope', '', {})
    zh._force_connection_close = 1
    hs.install_handler(zh)
    sys.ZServerExitCode=0
    asyncore.loop()
    sys.exit(sys.ZServerExitCode)

def populateFolder(folder, folder_type, doc_type):
    """ Creates a structure like:

    \index_html
    \doc1
    \folder1
       \folder11
       \folder12
       \doc11
Esempio n. 9
0
                raise
            # Handler for a published module. zhttp_handler takes 3 arguments:
            # The name of the module to publish, and optionally the URI base
            # which is basically the SCRIPT_NAME, and optionally a dictionary
            # with CGI environment variables which override default
            # settings. The URI base setting is useful when you want to
            # publish more than one module with the same HTTP server. The CGI
            # environment setting is useful when you want to proxy requests
            # from another web server to ZServer, and would like the CGI
            # environment to reflect the CGI environment of the other web
            # server.
            try:
                del HTTP_ENV['HTTPS']
            except KeyError:
                pass
            zh = zhttp_handler(MODULE, '', HTTP_ENV)
            if FORCE_HTTP_CONNECTION_CLOSE:
                zh._force_connection_close = 1
            hs.install_handler(zh)

    # HTTPS Server
    if HTTPS_PORT:
        ssl_ctx = SSL.Context('sslv23')
        ssl_ctx.load_cert_chain('%s/server.pem' % INSTANCE_HOME)
        ssl_ctx.load_verify_locations('%s/ca.pem' % INSTANCE_HOME)
        ssl_ctx.load_client_CA('%s/ca.pem' % INSTANCE_HOME)
        #ssl_ctx.set_allow_unknown_ca(1)
        ssl_ctx.set_session_id_ctx(MODULE)
        ssl_ctx.set_tmp_dh('%s/dh1024.pem' % INSTANCE_HOME)
        if X509_REMOTE_USER:
            ssl_ctx.set_verify(SSL.verify_peer, 10)