The power of Python

13/01/2005 02:10 | Categories: Blogging | 3 Comments 

In one my posts a couple of days ago I mentioned that I had started to look into Python for Series 60, recently released by Nokia. Of course in order to get up to speed with Python and the whole XMLRPC thingie in Python I needed to play around with it for a while, since my target is to build a simple moblogging client that will allow to post text and pictures to blogs via the Blogger and the metaWeblog XMLRPC APIs (since Nokia's Lifeblog does not support my 6600)

Look how simple it is to interact with the xmlrpc.php endpoint available in this server (all this from the Python console, the one that you get when typing just "python" at the command line):

import xmlrpclib
srv = xmlrpclib.ServerProxy( "http://www.francesc.net/xmlrpc.php" )
srv.metaWeblog.getRecentPosts("2","oscar", "xxxxx")


and the output (too long to be included here) is a native Python list including all the recent posts in my blog (that magic number "2" is my blog id)

This is something that I had never seen so far... The good thing is that there is no such Python method called "metaWeblog.getRecentPosts" in the ServerProxy class! The XMLRPC library is in fact doing some run-time detection of the method we're calling and in fact, it is contacting the XMLRPC server and sending a request to the "metaWeblog.getRecentPosts" method so this library would work equally good if the method was called "myServer.getSomething".

That's quite unbelievable and this probably is the easiest XMLRPC library I've ever seen. And the best thing is that it works just fine in my 6600 without any change! In fact, I was typing these very same lines above in my 6600 via the bluetooth console (yeah, that's another one you've got to see... connecting to the 6600 via Bluetooth and executing Python code there typed from my laptop)

This is probably sooo old news for the Python crowd but it is something that I am really excited about :) Now I think that the hardest part about building my dreamed moblogging client for Series60 will be to build the UI and make it responsive... I will keep you updated :)


Comments

3 Comments

  1. Ignasi 13/01/2005 23:13 | Error

    I tried to do the 3 lines that you wrote, adapted to my blog in www.lamevaweb.info, but when I run it, I have this error:
    server error. requested method metaWeblog.getRecentPosts does not exist.'>

    I know that your blog, is not a forum, but....

  2. oscar 14/01/2005 00:12 | 0.3.2 does not support metaWeblog

    the version of xmlrpc.php that lamevaweb.info is using is not the latest one. We added support for the metaWeblog API only a few days ago so it will only be available once 1.0 is out. Or if you still want to play with it, the 0.3.2 version of xmlrpc.php only supported the Blogger API so it's safe to play with only those.

    But you can download 1.0 from the subversion repository and start playing with it :)

  3. Ignasi 14/01/2005 03:43 |

    I don't know what I was thinking. I knew that www.lamevaweb.info have the old version of plog, but I didn't remember this version haven't got metaWeblog API, perhaps you explained me last summer.

Add comment
 authimage