Migrating from Plone to WordPress is not quite as straightforward as it may seem. In fact, it was quite a PITA. One of the factors for this was that none of us (except for @kagesenshi) have deep technical expertise on the innerworkings of Plone, or Zope. There was one solution, but reading through it, I know it would be a PITA.
So I decided that the best solution would be to parse Plone’s RSS feed and import them to WordPress’ MySQL database. This seems to be the most sensible, effective and headache free solution – provided that your Plone entries (articles, news, etc) combined are not in thousands.
The first thing that you need to do is to aggregate the entire Plone site. The steps to do this is well documented here.
The RSS by default will publish only 15 items. You have to change the RSS’ setting to, well, a very large number if you want to parse all the contents. This can be done by navigating to
synPropertiesForm of the Plone site.
So now you will have all the site’s content in RSS. Parsing the RSS is easy. My first attempt was to use ElementTree, a library that I always use whenever dealing with stuff XML-ish. Apparently it didn’t work properly, so I used feedparser instead.
Here’s a snippet of the code that does the job. This code reads a RSS file. feedparser can also retrieve the RSS remotely.
import feedparser import os import sys import MySQLdb as mdb # get this from the db # post_author id # mel => 1 # sniffit => 2 # klks => 3 # apparently unicode is not handled properly eventhough uft8 is aleady set, so edit the RSS file and remove Unicode chars first if __name__ == '__main__': file = sys.argv if not os.path.exists(file): print "Error: Unable to find file: " + file sys.exit(1) dbname = "yourdb" dbpass = "yourpassword" dbhost = "localhost" dbuser = "youruser" conn = mdb.connect(dbhost, dbuser, dbpass, dbname, charset="utf8") cursor = conn.cursor() f = feedparser.parse(file) l = len(f['entries']) print "Processing %d entries" % l for post in f['entries']: title = post.title link = post.link content = post.description content = content.encode('utf8') postdate = post.date slug = link.split("/")[-1] author = post.author post_author = "" if author == 'mel': post_author = "1" if author == 'sniffit': post_author = "2" if author == 'klks': post_author = "3" print "Importing post " + title q = "INSERT INTO wp_posts (post_date, post_date_gmt, post_content, post_title, post_name, post_author) VALUES (%s,%s,%s,%s,%s,%s)" cursor.execute(q, (postdate, postdate, content, title, slug, post_author)) conn.commit() cursor.close() conn.close()
There are a few things that this script doesn’t do, namely tags and categories. This can be coded, or done manually. Also, the RSS’ HTML output as generated by Plone may contain some garbage or wayward HTML tags (which are pretty consistent in around 80% of contents) and this can be cleaned up manually or by code.
Share this article
After a long battle with Plone, we have finally decided to migrate the WordPress. When we started, we used Trac, then Plone, and now WordPress. Why the change?
With Plone, we wanted to have a system that can manage membership. For example, members can view their membership status, renew their membership, and be sent notification when membership fees are due. However, Plone doesn’t have this feature built-in, and we don’t have enough expertise to hack Plone. As far as membership management is concerned, we don’t have members in the hundreds, so I have been using a simple excel file to keep track of members and payment.
With Plone, we also wanted a system for event management, and Plone is great for that. The calendaring system rocks. It was tightly integrated with Twitter, so new events that are added will be tweeted out immediately. Posted items are integrated to the mailing list, so any new posting will be sent to the mailing list. The calendar and event system are the only function in Plone that works for us.
So Plone had been used primarily to blog. However, it is a monster. It’s slow, non-intuitive, and even the easiest of tasks such as adding multiple photos to a post seems daunting. This has been a major discouragement, and one of the primarily reasons why we seldom post new stuff (you can point the finger at Mr. Lazy too).
And so we decided to move to WordPress. WordPress has everything we need (we still don’t need the membership management thingamagick). The only exception is the event and calendar system that worked for us in Plone. For that, we chose Google Calendar Event, a really nice and functional plugin for WordPress. It is not as awesome as the one that we have in Plone (as @kakeman has repeatedly pointed out, ad nauseum), but it works. One limitation is that new events that are added are not automatically tweeted. If you know how to integrate Google Calendar with Twitter notification, do let us know.
As for migration from Plone to WordPress, it was a pain in the ass, and will be the subject for another post.