Moving to MetaWebLog API

Getting BloGTK to play nice with PyBlosxom
Updated xmlrpc_metaweblog.py for PyBlosxom, as used on Copia

Eric Gaumer and Ted Leung continue to be my main support in getting up to speed with blogging in general and PyBlosxom in particular. Thanks, guys. Always easier to go a-hacking when you have fellow hackers in the trenches with you.

So Eric's entry was a nudge to finally get MetaWebLog going on Copia. First of all, I applied his patch to BloGTK. Then I set up xmlrpc_metaweblog.py. But first I had to update it to follow my convention of storing entries within directories for each date. If anyone else would like to go with that convention, you might want to check out my custom version of xmlrpc_metaweblog.py, linked above.

I'll specify a trackback when posting, to see if it does the trick. I'll post a comment with the apparent results.

But first of all, I'll save my blog entry to a local file. I'll be doing that a lot while using BloGTK. It has exhibited a few weird, not-obviously-reproducible quirks from time to time that worry me a bit. Unfortunately, the author has apparently abandoned the 1.1. branch in favor of BloGTK2, so I guess there will be some more hacking to do. Lucky thing I know Python. Even luckier thing Eric's learning Python so rapidly. At least the BloGTK2 preview looks cleaner. I'll look forward to it.

[Uche Ogbuji]

via Copia

Cookbooked, indeed

I learned from James Kew's blog that one of my Python Cookbook contributions made the second dead tree edition. He even has a nice pic scanned in:

12.10 Merging Continuous Text Events with a SAX Filter

Pas mal, ça. I should point out that I have an even more souped up version of that code available as part of Amara (class amara.saxtools.normalize_text_filter).

Hey, best news of all is that I suppose that means I'll be getting a copy of that book sometime soon (others, including Kew, have reported already getting their copies, but mail trucks struggle a bit making the chug up the hills to the Front Range). Bet. I'm looking forward to it.

[Uche Ogbuji]

via Copia

Serving up UTF-8 in PyBlosxom

It's 2005, people. No room for blogs and other sites without the most basic underpinnings of i18n. Turns out serving up UTF-8 from PyBlosxom is not the complete slam dunk I expected. To be fair, getting it to send UTF-8 was easy, given instructions in the config file. You want to add to your config a line such as:

py['blog_encoding'] = "utf-8"

This does cause PyBlosxom to render UTF-8 pages. But you also have to be sure the browser knows the pages are in UTF-8, or most browsers I've found will default to ISO-8859-1 and thus garble non-ASCII characters. I tried using HTML meta, by adding the following to the head template for my flavor (head.copia):

<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />

But this was not enough. Browsers rightly prefer to believe the HTTP content type header, so the trick lies in the content_type template for your flavor. Most HTML templates you find out there contain only text/html. You want to expand this to

text/html; charset=UTF-8

Your browser probably gives you a "page info" display of some sort with which you can check that your content type header is right. In Firefox 1.0.2 it's Tools -> Page Info or Ctrl+I. See the following example dialog:

Firefox page info dialog for Copia

[Uche Ogbuji]

via Copia

Help with trackback.py and autoping

Other PyBlosxomers have been nice enough to listen to my various gripes about plug-ins and extras, and to lend a hand (thanks guys: that was quick).

Ted Leung rolled in the various changes to trackback.py that I'd accumulated from various other hackers. If you use trackbacks in your pyBlosxom install, get the latest from ted's site. Looks as if he also has an updated version of commentAPI.py, so I copped that. He added a plug-in, xmlrpc_pingback.py, but I wasn't sure precisely what it did since it didn't have the standard plug-in doc header. I may pore through the code when I get a chance.

Eric Gaumer put a lot of work into the autoping plugin. He hasn't released his patched version, but I'll look out for it soon. He tried to use it to ping back my site, but apparently my trackback/pingback RDF was wrong. I think I've fixed it. If you try to ping Copia through a comment URL and it fails again, please let me know.

[Uche Ogbuji]

via Copia

Using post date for PyBlosxom file hierarchy

download customized xmlrpc_blogger.py
download patch to xmlrpc_blogger.py

Most PyBlosxom tools seem to like the pattern of piling all blog entry files into the top-level datadir, or using at most one level of hierarchy in the form of simple categories. Yuck. Here is an example of resulting ugliness: I like to post entries entitled Quotidie every day. It used to be in Copia that the first one gets lumped into top-level as Quotidie.txt. When I post the next one using BloGTK, the XML-RPC back end would detect a filename clash and choose an alternate file name such as Quotidie5gJS68ade.txt. It would be nice if it could pick a prettier means for disambiguation (e.g. Quotidie.txt). I understand this wouldn't be all that easy to do because of problems with race conditions, but of course, it would be nice if such clashes were just extremely rare in the first place.

IMO The obvious way to do this is to use the date for disambiguation. I'm sure others have done such things (there is at least one plug-in I've seen that uses an embedded date in the filename to preserve the posting date), but I couldn't find very much about this idea on the Net. I ended up just looking into what it would take to hack something for Copia. The goal is to have each entry in a hierarchy according to date so that yesterday's Quotidie would be found in:

$datadir/2005/04/07/Quotidie.txt

and today's in

$datadir/2005/04/08/Quotidie.txt

I use keywords rather than categories for PyBlosxom, so the directory structure has no semantic meaning for purposes of Copia. Since I usually post through blogging tools over xml-rpc, it turned out that it was enough to patch xmlrpc_blogger.py. While working on this plug-in I recoiled at how the file naming code is thrown carelessly into the body of the newPost function. I broke that functionality out into a new function blog_document_name, which returns the name of the file for the blog entry. This makes it easier for people to hack their own naming algorithms. My specialization implements the date-based hierarchy described above.

It seems there is still some work to be done. For one thing BloGTK doesn't seem to be able to find the files within this hierarchy when looking for postings to edit or delete. For another, PyBlosxom seems to get confused because permalinks to entries within the date-based hierarchy pulls in other entries as well as the intended one. I guess I have to learn more about how PyBlosxom manages its $datadir.

Update: I figured out this problem. PyBlosxom looks for discrete dates and years in the request URL, in order to handle requests for "all entries on day D". Turns out that a URL component of the form "20050408" doesn't trip this algorithm, so I just went with a structure of the form:

$datadir/20050408/Quotidie.txt

See the top of this post for links to to my custom xmlrpc_blogger.py and a patch from the xmlrpc_blogger.py shipped in the PyBlosxom contrib-1.2 package. I hope it helps someone else.

[Uche Ogbuji]

via Copia

Keywords on Copia

We started out by using PyBlosxom's categories here on Copia, but they were clearly never going to quite cut it. We needed multiple categories. Thankfully I found Bill Mill's keywords plugin (this is probably a more permanent link). It's one of the few PyBlosxom modules I haven't had to hack to get working. I did have to spelunk in his code to figure out that the $keywords story template variable has all the keywords for a specific story: this part was not documented in the doc string of the plug-in (it mentions the $all_keywords variable, which is more useful in other templates in a flavor).

[Uche Ogbuji]

via Copia

Getting autoping to work in pyblosxom

Man. PyBlosxom is mad sweet, but it takes a lot of hacking to get it properly tricked out. Just when I got trackback working here on Copia, I decided to try autoping.py a shot, and it broke into several pieces as soon as I tried to use it. I fixed the first, second and third traceback before giving up. Clearly it needs even more work than trackback.py did, and I'm still limited by PyBlosxom newbeing.

Good thing DJ Revolution is playing right now. Keeps me in a Colorado Kind mood no matter what. I guess I know what some people feel like when they make their first foray into 4Suite. Well, I guess I've always known.

[Uche Ogbuji]

via Copia

Getting trackbacks to work in pyblosxom

Ted Leung's trackback.py module for pyblosxom is pretty badly broken. Hard to imagine it ever worked at all, but I had to have another full immersion into PyBlosxom plug-in land to try to figure fix it. I got some ways by myself beefore I went to seek help on the 'Net and found Eric Gaumer 's message and blog entry with some of the fixes I'd figured out, and some others. I also found some improvements from Steven Armstrong. In a similar thread, I learned from Joseph Reagle about this useful Web page for sending trackback pings.

Ted Leung seemed receptive to the fixes and said he had an update version of trackback.py, but I couldn't find it, so I just made the changes myself. I've posted the updated file here (trackback.py), in case anyone wants it. I'll probably remove the file once I see a fixed version in the spot pointed to by the PyBlosxom registry.

BTW, Eric's a fellow snowboarder, and he's scored a trip to the Mammoth this year. Sweet. I wonder how many other Pythonistas shred.

[Uche Ogbuji]

via Copia

PyMarkdown for PyBlosxom

download

The PyBlosxom plug-in registry lists pymarkdown.py, by Tollef Fog Heen as a PyBlosxom plug-in. Odd thing is that the downloaded file seems to implement Markdown just fine, but not the PyBloxsom plug-in API.

So I hacked up this script that does so. It's basically http://err.no/pymarkdown/pymarkdown.py with the PyBlosxom plug-in stuff implemented. I'm truly a Blosxom newbie and I just did a cut&paste+hack from other plug-ins I saw, but it seems to work for my blog.

[Uche Ogbuji]

via Copia