Random notes from mg

a blog by Marius Gedminas

Marius is a Python hacker. He works for Programmers of Vilnius, a small Python/Zope 3 startup. He has a personal home page at http://gedmin.as. His email is marius@gedmin.as. He does not like spam, but is not afraid of it.

Sat, 16 May 2009

Enabling comments in PyBlosxom

I've just spent the whole night setting up blog comments. PyBlosxom doesn't make it painless, sadly, more like the opposite.

First: don't be scared by the list of comment-related plugins on the PyBlosxom site. There's only one important plugin: comments. All others depend on it and enhance its functionality. The last three or four times I was about to add comments to my blog I got scared at step one: evaluate the available plugins. Don't repeat my mistake!

Second, follow the instructions carefully. There's no shortcut.

Third, fix what's broken. Be prepared to debug the source code. print >> sys.stderr, "message" is your friend.

Fourth, fiddle with the look (CSS and HTML).

Fifth, write a blog post and eagerly await your first comments.

Step 3 screams for an explanation, doesn't it? Problem 1: the comments plugin requires that you use categories in your blog. I'm not (I'm holding out for tags). Workaround: comment out if entry['absolute_path'] check in cb_story and cb_story_end.

Problem 2: the AJAX post returns "Empty response from server". Workaround: modify cb_story_end to call readComments directly if entry['num_comments'] is None, since cb_story, which usually does the read, is not called during the AJAX post.

Problem 3: if you enable comment moderation (by setting comment_draft_ext to a different value from comment_ext), the AJAX post returns "Empty response from server" once more. Workaround: modify cb_prepare to notice this case and set data['moderated'] = True, create a new template comment-moderated and render it in cb_story_end just like the preview template is rendered; also modify __shouldOutput to return True when rendering comment-moderated.

I'll post patches to the pyblosxom mailing tomorrow, unless I forget. It's 6 am already, and I'm kind of sleepy. I just hope I haven't inadvertently broken my RSS feed or flooded any planets.

Oh, and a helpful hint: don't name the post you're writing comments.txt, or the #comments anchor will point to the start of the story instead of the comments.

posted at 06:13 | tags: | permanent link to this entry | 8 comments
And this is how the comments look.

Not everything is perfect, e.g. the comment body sanitization is kind of stupid (inserts br for every newline even inside pre, doesn't let me enter a less-than sign --- escapes ampersands but doesn't escape tags).
posted by Marius Gedminas at Sat May 16 06:12:27 2009
Also, I wish the blog offered me to store my personal info in a cookie.

Also, I broke error reporting fixing problem 3 (or maybe it was broken before): if the web server has no permissions to write to your comments dir, it misleadingly tells you that everything's fine.
posted by Marius Gedminas at Sat May 16 06:17:05 2009
Hello,

this is a test comment on your comments.  All seems to work ok.... well the preview does... let's see if the Submit works...

Does anyone say comment out loud?  Seems like one of those words read and never said.

cu,
posted by Rene Dudfield at Sun May 17 04:29:08 2009
At last!
posted by tori at Sun May 17 12:22:15 2009
Just to clarify things a bit, the comments plugin is a contributed plugin--it's not part of PyBlosxom core, you don't have to use it, there are some alternatives (disquss, ...), and it sounds like comments needs some serious tlc.

It definitely needs someone to take up the banner to provide that tlc.
posted by will at Mon May 18 15:52:03 2009
Well, a sufficient number of spammers have found the blog now that I've enabled the Akismet plugin.  I had to fiddle with comments.py again to make sure the rejection message is displayed.
posted by Marius Gedminas at Fri May 29 15:23:10 2009
Warning: comments.js by Ryan Barrett, while very nice, has a bug in it: it uses escape() instead of escapeURIComponent().  This is a bad idea since it fails to handle non-ASCII characters correctly.
posted by Mariūs Gædminas (not my real name) at Wed Sep 16 16:02:24 2009
Thanks for the help here. I've spent almost 2 days trying to re-enable the comments plugin on my website. The entry['absolute_path'] was really screwing me up.
posted by Christopher Baus at Sun Nov 29 05:29:00 2009

Name (required)


E-mail (will not be shown)


URL


Comment (some HTML allowed)