[Zope] TCPWatch... and closing sockets..

Steve Spicklemire steve@spvi.com
Sun, 21 Jan 2001 17:15:28 -0500 (EST)


I'm going to try to make a long story short... and the story isn't even
over... but I'm getting close. One of our clients is a 'multimedia'
company and we're working with a group there that consists mostly
of artists and designers who use tools like photoshop and 
macromedia director. They came to us recently with a project
for which they were *going* to use Macromedia Multiuser Server
but the complexity of their application is significant.. 

long story short... I've sold them on the concept of using Zope as the
'media/personality server' for this application.  They will use
Director (which can post stuff to an URL and can also parse
XML). So.. I'm building a framework that permits them to use their
favorite tools, but I get to use *my* favorite tool too. ;-) The
problem: Director is not a browser. There is no 'view source'. But (I
think to myself) this is a great chance to use tcpwatch, which I've
never used before. It's a little tricky since my favorite client
machine is a Macintosh, and well.. lets just say that Tkinter for the
mac is not perfect... not to mention there is no thread module..  but
I do have a workaround that's useful (since I run Zope on a FreeBSD
server, I just use tcpwatch on FreeBSD and either MI/X, or VirtualPC
with Linux for my X server.. ). I noticed however that when I did a
'POST' the URL encoded arguments were lost. I found that the
proxy_receiver handle_close method was never called.. so that anything
in a 'last line' that didn't end in '\n' was lost. I added the
following patch that shows this... but why is handle_close not called?
I can only guess that the socket is not being properly closed
somehow. I use lib/python/ZPublisher/Client.py to test calls to Zope
and it works fine, but the asyncore/asynchat stuff never calls
handle_close for proxy_receiver.

Anyway... here's the patch: Comments welcome!

*** ./tcpwatch_orig.py Sat Jan 20 16:55:43 2001
--- ./tcpwatch.py       Sun Jan 21 16:52:11 2001
***************
*** 130,135 ****
--- 130,137 ----
                  pos = pos + 1
              else:
                  # Last line, may be incomplete.
+                 line = "Partial line? " + data[oldpos:] + '\r\n'
+                 self.watch_output(line, byClient)
                  return data[oldpos:]
          
      def cleanupRefs(self):

take care,
-steve