[Spambayes-checkins] spambayes/spambayes Dibbler.py,1.1,1.2

Richie Hindle richiehindle at users.sourceforge.net
Tue Jan 21 10:23:45 EST 2003


Update of /cvsroot/spambayes/spambayes/spambayes
In directory sc8-pr-cvs1:/tmp/cvs-serv19715

Modified Files:
	Dibbler.py 
Log Message:
You can now specify the local address to listen on, as well as the port.
Thanks for Tony Lownds for the patch.


Index: Dibbler.py
===================================================================
RCS file: /cvsroot/spambayes/spambayes/spambayes/Dibbler.py,v
retrieving revision 1.1
retrieving revision 1.2
diff -C2 -d -r1.1 -r1.2
*** Dibbler.py	17 Jan 2003 20:21:07 -0000	1.1
--- Dibbler.py	21 Jan 2003 18:23:43 -0000	1.2
***************
*** 235,239 ****
          connections when Dibbler.run is called:
  
!          o port: The TCP/IP port to listen on
  
           o factory: The function to call to create a handler (can be a class
--- 235,242 ----
          connections when Dibbler.run is called:
  
!          o port: The TCP/IP (address, port) to listen on. Usually '' -
!            meaning bind to all IP addresses that the machine has - will be
!            passed as the address.  If `port` is just an int, an address of
!            '' will be assumed.
  
           o factory: The function to call to create a handler (can be a class
***************
*** 260,264 ****
          self.set_socket(s, self.socketMap)
          self.set_reuse_addr()
!         self.bind(('', port))
          self.listen(5)
  
--- 263,269 ----
          self.set_socket(s, self.socketMap)
          self.set_reuse_addr()
!         if type(port) != type(()):
!           port = ('', port)
!         self.bind(port)
          self.listen(5)
  
***************
*** 280,294 ****
      your content - see `HTTPPlugin` for detailed documentation and examples.
  
!     `port` specifies the TCP/IP port on which to run, defaulting to port 80.
  
      `context` optionally specifies a `Dibbler.Context` for the server.
      """
  
!     def __init__(self, port=80, context=_defaultContext):
          """Create an `HTTPServer` for the given port."""
          Listener.__init__(self, port, _HTTPHandler,
                            (self, context), context._map)
          self._plugins = []
!         context._HTTPPort = port
  
      def register(self, *plugins):
--- 285,303 ----
      your content - see `HTTPPlugin` for detailed documentation and examples.
  
!     `port` specifies the TCP/IP (address, port) on which to run, defaulting
!     to ('', 80).
  
      `context` optionally specifies a `Dibbler.Context` for the server.
      """
  
!     def __init__(self, port=('', 80), context=_defaultContext):
          """Create an `HTTPServer` for the given port."""
          Listener.__init__(self, port, _HTTPHandler,
                            (self, context), context._map)
          self._plugins = []
!         try:
!             context._HTTPPort = port[1]
!         except TypeError:
!             context._HTTPPort = port
  
      def register(self, *plugins):
***************
*** 336,340 ****
              method, url, version = requestLine.strip().split()
          except ValueError:
!             self.pushError(400, "Malformed request: '%s'" % requestLine)
              self.close_when_done()
              return
--- 345,349 ----
              method, url, version = requestLine.strip().split()
          except ValueError:
!             self.writeError(400, "Malformed request: '%s'" % requestLine)
              self.close_when_done()
              return





More information about the Spambayes-checkins mailing list