||[May. 15th, 2006|09:56 am]
Man, I have a lot of things on my mind!
So Prop 6 passed here in Austin (allowing the city to give health benefits to same-sex couples). I gotta say, it feels really good to finally win on a gay issue here in Texas. Yay!
djedi and I went to his brother's graduation in College Station Saturday morning. It was nice, although the ceremony itself was fairly boring (naturally) and it was fairly chilly inside. We went out to lunch afterwards and we got to meet his girlfriend, who was nice. I also took a toooon of pictures that I need to sort through at some point. A&M wasn't too scary - they say "Howdy" a lot (I could get used to that!), and there was some whooping, but it's all good. wonderjess graduates next weekend, so I'll be flying up to sunny (and hopefully not too cold!) Rochester on Friday.
So, going into the weekend the backend was written mostly (I could update my google calendar by running a ruby script from the command line), so I needed to put a web interface on top of it. This was tricky for a number of reasons.
First of all, the way I have to do authentication with Google right now, I have to ask for the user's Google username and password. They're working on a different way to do this, but for now this is what's required, so I wanted to make sure the page was using HTTPS to collect that information. I set up a certificate (that I signed myself - not worth paying $50 or whatever it costs to have someone else sign it) and after a few hiccups, got things working.
Then I started thinking about how this was actually going to work. The problem is that deleting and adding the entries will take at least 30 seconds, and sometimes much more, so I wanted an asynchronous way to do it. I had read some stuff about Comet, which is a bleeding edge application model. Basically, the idea is that the client opens a long lived connection to the server, and because of this the server can push back data whenever it wants (which isn't possible under normal HTTP). This sounded perfect, because I could connect to the server when the user pressed "Upload", and the server could send back progress updates while it was working, and have the client close the connection when it was done.
So, great. There are some problems. One is that web servers that aren't aware of a Comet-like approach don't scale this approach very well - having lots of connections open for a long time. That's OK for me, I'm not worried about too many people using this thing all at once :-) The other problem is that apparently it's hard to get working correctly. It was hard to find easy to understand examples that actually use this approach, and the one that I did find and understand relied on having the server basically return a text stream that gets progressively updated. I could not for the life of me make this happen correctly - it would wait until the whole thing was done, then display the whole stream, which obviously wouldn't work. I looked around for some other way to do this, and found a Mozilla/Firefox-only solution which was no good. So finally I threw up my hands and gave up on Comet for now. Maybe I'll take another look at it in the future.
So, I decided that the request to upload would finish quickly and return a session ID, and the client could call a script to get the status of that session every few seconds, which would simulate the same effect. This required some way to share session data across ruby processes, and CGI::Session turned out to be perfect for me - it by default stores session data in a file, so I can just read that file when I receive a request to get status.
I was also baffled for a while that I was receiving the file correctly, and processing it with pilot-datebook, but the resulting file in longtxt format wasn't showing up. After butting heads with the problem for a while, I realized that I was using Tempfile to generate a temporary filename, but it was deleting the file as well, so that was an easy fix.
So most of the hard problems have been solved - I still need to do the processing and integrate that with status reports (and abstract that part out so I can still use the command-line version), and I need to handle errors better (at all :-) ), but I'm very happy with where things are right now.
...in short, things are going well.
Apparently having the NSA intercept domestic phone calls was Dick Cheney's idea, and NSA lawyers were against it.
51% of people disapprove of the domestic spying.