Monday, September 08, 2008

Playing with Wordpress and Python and the metaWeblog API

For those who know me, they know I work for the Hurricane Research Division and the Surface Wind Analysis group (http://hurricanewinds.noaa.gov). Well anyways we've been wanting to move forward with a new product site, something more up to date with the status of the web and the world. Anyways initially my plan was to customize Trac, which we use as our project management package, as the 'engine' for controlling our new website. I saw the built-in Wiki tools and RSS feeds as the driving force. But the more I looked at it, I began to think that I was going about it the hard way. One of the goals in my mind was to have an RSS feed for our analysis and with the availability of a variety of blog tools, I knew there had to be a better way.

Anyways weekend before last with Hurricane Gustav, we found that the building FTP server was getting overloaded and denying access to many people who needed it, this also prevented many people from gaining access to our analysis, especially a number of Emergency Management people. I right away started looking at an alternative.

Since I was already looking for alternative solutions to my Trac idea, my first thought was to setup some kind blog. Being that I'm a Blogger user (as you can tell by this blog), I first looked at Blogger. My first thought was to setup an automatic email solution posting to Blogger. Try as a might using mail and other CLI mail tools for Linux, I couldn't seen to figure out how to get my attachments sent and actually present a post with some sort of decent layout. Next I looked at Wordpress.com, but they didn't have a email option and I didn't think it was going to be straight forward to send images to the blog.... Well by this time Gustav had already made its landfall along the Louisiana coast, so I said forget it and went on.

Well that didn't last long... I looked out on the horizon and new that Ike was going to be just as much trouble as Gustav was when it came to internet traffic. I knew I needed to find that solution. So back to the blog engines I looked. This time I went a different route... when I first started with the idea of customizing Trac, it already meant that I was going to have to host my own site, so why not now. So back to WordPress. This time to Wordpress.org and its 5-minute installation guide. They weren't kidding, in 5 minutes I was up and running a basic Wordpress blog. But so what... I still needed to figure out how to post to my new blog and still I needed to figure out how best to post my images...

Well for the images I cheated.... I'm not posting them to the actual blog,  I decided to simply store them at location accessible by WordPress (basically in another directory on my webserver). So that solves that problem, now all I need to do is create a blog posting tool that sends a nicely formatted blog post with links and standard img tags. No problem... in steps my new favorite language Python, which I started working with back in March (other posts).

I already knew that Python had lots of built-in default packages for working with the Web, heck, Trac is completely written in Python, what I didn't realize was how easy it was to work with. One of the built-in modules is an XML-RPC module which is all you need to start writing a Python program to post to WordPress (or most blog engines for that matter). The XML-RPC module can work with most of the blogging APIs including MovableType and the MetaWeblog API. For WordPress I went with the MetaWeblog API, WordPress implements MovableType API and the Blogger API, the MetaWeblog API was in my mind more generic and most likely more useful for me later down the line.

Anyways when I started writing this post I was planning on including snippets of my Python code but as since this post has gotten to long, I think the snippets would get lost and not be of much help here, so I'll write a second post that deals strictly with using Python to write to a WordPress blog.

So to get to the conclusion, check out http://storm.aoml.noaa.gov/wordpress to see the setup. I chose the Blocks2 theme from by mg12 and I also installed a PDA/iPhone plugin for mobile browsing. Plugins is where I find the big power of WordPress falls. There are so many plugins available that basically there is a plugin for everything. I'm sure other 'hostable' blog engines like MovableType and such have as many plugins, but for now I'm sticking with WordPress. I've got it setup and since it works, I don't think I'll be looking at the others for some time... or at least until I get bored with my current setup.... Oh one other plus for WordPress, its FREE!

As for this blog... I think it will remain a Blogger blog. For now Blogger works for me... I do however see myself switching to Wordpress eventually, but not until I finally choose a domain name and actually break down and get a hosted solution. WordPress is great, but the free version available at WordPress.com is just to much of a tease when you know what WordPress can do and how easy it is to setup.

As for my code snippets... I'll post that tomorrow.

No comments: