Migrating to WordPress

In case you didn’t notice, I’ve migrated my blog to WordPress.

Why you ask, since we have Plone. Well, nothing special. Just that
I wanted to avoid the temptation to keep tweaking my
wires-and-bubble-gum blog installation on top of a really old Plone
installation and have something that would just work.

So, if you’re in a similar situation and want to give WordPress a try,
here’s the script I used to exporting my blog entries in the Movable
Type export format for importing into WordPress. It should export
categories and comments and everything in the proper format. It worked
for me didn’t it? :O)

## Script (Python) "mtexport"
##bind container=container
##bind context=context
##bind namespace=
##bind script=script
##bind subpath=traverse_subpath
out = context.REQUEST.RESPONSE
sort_modified = context.sort_modified_ascending
get_discussion = context.portal_discussion.getDiscussionFor
reply_replies = context.getReplyReplies
a_dict = {}

def spit_comments(comments, out):
      im_in_sub = False
      for comment in comments:
         if same_type(comment, a_dict):
           im_in_sub = True
           comment = comment['object']
         print >> out, 'COMMENT:'
         print >> out, 'AUTHOR:', comment.Creator()
         print >> out, 'DATE:', comment.created().strftime('%m/%d/%Y %H:%M:%S')
         print >> out, '<strong>', comment.Title(), '</strong>', '<br>'
         print >> out, comment.CookedBody()
         print >> out, '-' * 5
         if not im_in_sub:
            spit_comments(reply_replies(comment), out)
      null = printed

for entry in context.blog.objectValues():
   print >> out, 'TITLE:', entry.Title()
   print >> out, 'AUTHOR:', 'sidnei'
   print >> out, 'DATE:', entry.created().strftime('%m/%d/%Y %H:%M:%S')
   print >> out, 'STATUS:', 'publish'
   print >> out, 'ALLOW COMMENTS:', '1'
   print >> out, 'ALLOW PINGS:', '1'
   print >> out, 'CONVERT BREAKS:', '0'
   cats = entry.Subject()
   if cats and cats[0].strip():
      print >> out, 'PRIMARY CATEGORY:', cats[0]
   for cat in cats[1:]:
      if cat.strip():
         print >> out, 'CATEGORY:', cat
   print >> out, '-' * 5
   print >> out, 'BODY:'
   print >> out, entry.CookedBody()
   comments = sort_modified(get_discussion(entry).getReplies())
   if comments:
      print >> out, '-' * 5
      spit_comments(comments, out)

   print >> out, '-' * 8

null = printed
return out

So if you succesfully use that, drop me a note.


2 thoughts on “Migrating to WordPress

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.