Pyblosxom MetaWeblog plugin: patch to generate meaningful filenames

The MetaWeblog plugin for Pyblosxom (xmlrpc_metaweblog.py) generates new blog entries in files that are named as a incrementing sequence of numbers (based on total entry count). That isn’t very helpful when trying to find the source of a blog entry to edit.

I don’t program in Python, but it is a straightforward language to work with. Some googling gave me enough code snippets to figure out what to do. The patch below changes the filename logic to be based on the title and the current timestamp. This format is also helpful with respect to my use of the filenametime plugin (pyfilenametime.py), which allows the date/time embedded in the filename to override the file timestamp for purposes of determining the blog post timestamp (so I can edit previous posts without affecting the order).

 390,391c390,392 <     count = _getEntryCount(request)      pattern = re.compile('[^a-zA-z0-9]+') >     title = pattern.sub('-', struct['title']) >     date_time = time.strftime('%Y-%m-%d-%H-%M') 393c394          postId = os.path.join(category, "%s" % (title + '.' + date_time)) 395c396          postId = os.path.join("%s" % (title, '.', date_time)) 

WeblogsPing plugin for Pyblosxom has transient problems

I noticed today that whenever I edit an existing post via a file editor and save it, the first refresh to my Pyblosxom generates an HTTP 500 error. Since the logging is terrible for Pyblosxom (or I’m ignorant on how to make it better), I disabled all my plugins and progressively enabled them, testing at each step.

I don’t know what the ultimate source of the problem is, but it’s clearly the Weblogsping.py plugin that’s associated with the behaviour. With that plugin, editing a file causes the first refresh to have an error; subsequent refreshes behave as expected.

Fortunately, that plugin was only there as an afterthought – it doesn’t matter much to me to be pinging blog aggregators.

Change of blog software: Blojsom to Pyblosxom

The obvious revamp of my blog’s appearance also reflects a change of the blogging software underneath.  I switched from Blojsom to Pylosxom.  Both are based on the Perl-based Blosxom.  The unifying principle of all three is that blog entries are stored as plain text files, rather than in a relational database like other, fancier packages (e.g. WordPress).

The main reasons for moving to Pyblosxom:

  • The next version of Blojsom, v3, is moving away from a file-based data store to a relational database (Apache Derby).  A simple blog-entry-per-file scheme is why I looked for something like Blojsom in the first place (easy to backup, easy to edit).
  • My server is a virtual machine with 96MB RAM.  Running a light servlet container (Jetty) for Blojsom takes 40MB – most of the free memory after all other services are running.
  • I like finding “better” ways of doing things.

I originally tried Blosxom, but I found it frustrating to get the plugins I wanted running.  I later reasoned that since Python is the “cool” language right now, Pyblosxom had a chance of being good and of progressing.  Compared to Blojsom, some of what I like about Pyblosxom:

  • Low resource footprint.
  • Load times are much faster (related to the lower resource footprint).
  • Tagging and Captchas, which were difficult for Blojsom, were easy.

The main features I miss from Blojsom:

  • Integrated administration webpages that can also be used to post to the blog.
  • Better XML-RPC support for various graphical blog posting tools.  The only one that worked while supporting categories was Deepest SenderBlogmailr, which I used to post to my blog via e-mail, will work only with Pyblosxom’s root category.
  • More active development of the base and of plugins.  Blojsom’s authour, David Czarnecki, is prolific.  Blojsom is also the default blog server for Mac OSX.
  • Better error handling.  Pyblosxom’s logging is poor (most errors result in an HTTP 500 error and a generic message in the Apache logs), and something as simple as a malformed metadata line (e.g. specifying the tags for the entry) or a zero-byte file will cause unrecoverable errors.
  • The Pyblosxom plugin MetaWebLog XML-RPC API creates new posts as sequentially increasing filenames – Blojsom created them based on the title of the blog post.

Overall, I’m happy with the result. Pyblosxom had a limited set of appearances to choose from. However, starting with the one I liked the most as the base, and with feedback from Firion, I was able to hack around with the plugins and CSS to get something I’m content with – for now anwyay. :)

Follow

Get every new post delivered to your Inbox.