Thursday, November 29, 2007

Colbie Caillat

Last month or so I heard "Bubbly" and just loved it. For past week I have been listening to "Realize" and I just adored the way Colbie Caillat can play her voice.

She has great talent and genuine voice. Halfway through "Realize" she just takes her time to play her vocal chords to create magic out of the words "didn't I tell you...".

It's not usual to find someone's live performance as good as their post processed published albums. If you see this live performance by Colbie, you will find an exception to that rule.

Tuesday, November 20, 2007

Firefox 3 is brilliant!!!

If you read this on slashdot this morning you must already know. I just tried it on my Mac OSx and the review is completely true.

Starting firefox 2 on my freshly booted MacBook was taking very very long time. It was unusually slow even after compared to sluggishness of firefox on Linux. Don't know why. So when I tried firefox 3 beta 1 on it I could clearly tell the difference. The fire in firefox is back.

[The only reason you might want to hold from upgrading just as yet is lack of availability of compatible plugins. As the official release nears, this problem will go away]

XML RPC server inside apache mod_python

Writing XML RPC server and client in python is extremely easy. There are many examples. xmlrpclib is part of python, so writing client doesn't need anything extra. There are many examples of XMLRPC server as well. I used Julien Oster's.

The problem comes when you want to use XML RPC server in a production environment alongside your apache web server. If you are not a big shop then you very likely want to host both of them on same machine. Then two different servers can't listen for HTTP on same port. You might use an alternate port (second in popularity to port 80), but the users behind corporate firewall will suffer. If you understand the protocol stack, you would know it shouldn't be difficult to run the XMLRPC server inside an apache server. I realized that last weekend, and in couple of hours I hosted Julien Oster's XML RPC server inside my apache mod_python framework.

Download the XML RPC server. You will find a single file xmlrpcserver.py.

You will find a class XmlRpcServer in it. That's all you need. Add following method to it:
    def handle(self,req):
length = int(req.headers_in["Content-length"])

request_string = req.read(length)
request = StringIO(request_string)

request.seek(0)
response = StringIO()

try:
self.execute(request, response, None)
except Exception, e:

return apache.HTTP_INTERNAL_SERVER_ERROR
finally:
response.seek(0)

rstr = response.read()
req.headers_out['Content-type'] = 'text/xml'

req.headers_out['Content-length'] = "%d"%len(rstr)

req.write(rstr)
return apache.OK

Now host the following code in your index.py file (or any python file you have configured as PythonHandler in your apache settings)

from mod_python import apache

from xmlrpcserver import XmlRpcServer

def handler(req):

try:
xmlserver = XmlRpcServer()
app = Application()

xmlserver.register_class('app',app)

result = xmlserver.handle(req)

return result
except Exception, e:
return apache.HTTP_INTERNAL_SERVER_ERROR

# The following class is where you can put your application logic
class Application:
def __init__(self):
pass

def getName(self):
return 'example'

Once you save the above index.py to your webserver, you can use a python client to invoke XMLRPC calls to your apache server.

Assuming you saved above file to $(DOCROOT)/xmlrpc/index.py, your client code would look like this:
import xmlrpclib

remote = xmlrpclib.Server('http://yourserver.com/xmlrpc/')
name = remote.app.getName()


And you are all set!

syntax highlighted by Code2HTML