Beispiel #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
Beispiel #2
0
    def setUpServer(self):
        """Create an FTP server instance and save it in self.ftpServer
        """

        from ZServer import logger
        from ZServer.FTPServer import FTPServer
        from StringIO import StringIO

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

        zopeLog = logger.file_logger(log)

        self.ftpServer = FTPServer(
            'Zope2',
            ip=self.host,
            port=self.port,
            logger_object=zopeLog,
        )
        # Refresh the hostname and port in case we dynamically picked them
        self.host, self.port = self.ftpServer.socket.getsockname()
        # 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',
        ):
            self.host = 'localhost'
            self.ftpServer.hostname = 'localhost'
            self.ftpServer.ip = '127.0.0.1'
        self['host'] = self.host
        self['port'] = self.port
Beispiel #3
0
    def setUpServer(self):
        """Create an FTP server instance and save it in self.ftpServer
        """

        from ZServer import logger
        from ZServer.FTPServer import FTPServer
        from StringIO import StringIO

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

        zopeLog = logger.file_logger(log)

        self.ftpServer = FTPServer(
            'Zope2',
            ip=self.host,
            port=self.port,
            logger_object=zopeLog,
        )
        # Refresh the hostname and port in case we dynamically picked them
        self.host, self.port = self.ftpServer.socket.getsockname()
        # 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', ):
            self.host = 'localhost'
            self.ftpServer.hostname = 'localhost'
            self.ftpServer.ip = '127.0.0.1'
        self['host'] = self.host
        self['port'] = self.port
Beispiel #4
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
Beispiel #5
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()
Beispiel #6
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()
Beispiel #7
0
    def setUpServer(self):
        """Create an FTP server instance and save it in self.ftpServer
        """

        from ZServer import logger
        from ZServer.FTPServer import FTPServer
        from StringIO import StringIO

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

        zopeLog = logger.file_logger(log)

        self.ftpServer = FTPServer('Zope2', ip=self.host, port=self.port, logger_object=zopeLog)
Beispiel #8
0
    def setUpServer(self):
        """Create an FTP server instance and save it in self.ftpServer
        """

        from ZServer import logger
        from ZServer.FTPServer import FTPServer
        from StringIO import StringIO

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

        zopeLog = logger.file_logger(log)

        self.ftpServer = FTPServer('Zope2',
                                   ip=self.host,
                                   port=self.port,
                                   logger_object=zopeLog)
Beispiel #9
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
Beispiel #10
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()
Beispiel #12
0
                    referer,
                    user_agent
                    )
                )

        from ZServer.medusa import http_server
        http_server.http_request.log = log

    # Resolver and Logger, used by other servers
    if DNS_IP:
        rs = resolver.caching_resolver(DNS_IP)
    else:
        rs=None

    if READ_ONLY:
        lg = logger.file_logger('-') # log to stdout
        zLOG.LOG('z2', zLOG.BLATHER, 'Logging access log to stdout')
    elif os.environ.has_key('ZSYSLOG_ACCESS'):
        if os.environ.has_key("ZSYSLOG_ACCESS_FACILITY"):
            lg = logger.syslog_logger(
                os.environ['ZSYSLOG_ACCESS'],
                facility=os.environ['ZSYSLOG_ACCESS_FACILITY'])
        else:
            lg = logger.syslog_logger(os.environ['ZSYSLOG_ACCESS'])
        zLOG.LOG('z2', zLOG.BLATHER, 'Using local syslog access log')
    elif os.environ.has_key('ZSYSLOG_ACCESS_SERVER'):
        (addr, port) = os.environ['ZSYSLOG_ACCESS_SERVER'].split( ':')
        lg = logger.syslog_logger((addr, int(port)))
        zLOG.LOG('z2', zLOG.BLATHER, 'Using remote syslog access log')
    else:
        lg = logger.file_logger(LOG_PATH)