< October 2006 >
SuMoTuWeThFrSa
1 2 3 4 5 6 7
8 91011121314
15161718192021
22232425262728
293031    
Mon, 16 Oct 2006:

I've been playing around with some stuff over the weekend, which eventhough runs in a browser, needs continous updates of data while maintaining state. So I tried to a socket-hungry version of server push which has been called COMET. Now, this technique has come into my notice because of a hack which bluesmoon did, except I had to reinvent for python what CGI.pm did for bluesmoon by default.

But first, I mixed over a couple of the client side bits. Instead of relying on XHR requests, which are all bound & gagged by the security model, I switched to a simpler cross-domain IFRAME. But what's really cool here is that I use a single request to push all my data through, in stages, maintaining state. So here's a bit of code, with technical monstrosity hidden away.

#!/usr/bin/python

import sys,time

from comet import MixedReplaceResponse

content = "<html><body><h1>Entry %d</h1></body></html>";

req = new MixedReplaceResponse()

for i in range(0,10):
	req.write(content % i)
	req.flush()
	time.sleep(3)

req.close()

The MixedReplaceResponse is a small python class which you can download - comet.py. But the true beauty of this comes into picture only when you put some scripting code in what you send. For example here's a snippet from my iframe cgi code.

wrapper = """
   <html><body> <script>  if(window.parent) {
		%s
	} </script></body></html>
""";

script = ("window.parent.updateView(%s);" % json.write(data))

req.write(wrapper % script)
req.flush()

As you can clearly see, this is only a minor modification of the json requests which I'd been playing with. But underneath the hood, on the server side, this is a totally different beast, totally socket hungry and does not scale in the apache cgi model. Interesting experiment nonetheless.

Now, if only I could actually host a cgi somewhere ...

--
To see a need and wait to be asked, is to already refuse.

posted at: 09:12 | path: /hacks | permalink | Tags: , ,

The first shortlist of talks for FOSS.in/2006 is out. Let me be the first to say that there are a couple of surprises there. First and very surprising one would be a talk by none other than spo0nman himself. Second was botsie talking about Gentoo - not about XFCE. Yet another, sort of surprise, with bluesmoon about libyahoo2 - I suppose he can indeed talk about it, though not commit stuff ?

And then, a few names were obvious by their absence. I don't see a talk by KingDiamond or BigBeard - And kryptic too is missing, which was probably not as much of a surprise (*click* *click*).

The talks list seems a bit biased towards the kernel/library/OS land and a little left of the eyecandy section, but I'm sure that is probably not a real problem. Just make sure one of the computers around is running Beryl with the keyboard on a recorded cycle with xsendkey.

--
I like the word "indolence", makes my laziness seem classy.
            -- Bern Williams

posted at: 01:53 | path: /conferences | permalink | Tags: ,