Pay No Attention to the TrackBack in the Corner


Posted

in


Okay.  I put together a really simple trackback implementation in Python last night.  I took a look at the trackback tech specs and have so far implemented the ping method.  The code below illustrates usage of the trackback library.

import tblib
tb = tblib.TrackBack("http://mt.develooper.com/mt/mt-tb.cgi/17",
"Python Test",
"I'm testing my Python TracbBack implementation...",
"http://postneo.com/2003/01/22.html#a1829",
"Matt Croydon::Postneo")
tb.ping()

Here’s the output for the above code:

200 OK
<?xml version="1.0" encoding="iso-8859-1"?>
<response>
<error>0</error>

The implementation does not know anything about auto-discrovery yet.  It also does not deal with error handling, it just prints out the response.  Future versions will handle both.  If you’d like to play, you can download the source: tblib-0.0.4.py.txt.

In order to run a script similar to the example I provided (which pings a page on Ask’s weblog), you’ll have to rename it to tblib.py and place it in the directory of the calling script.  Once the library is polished, I’ll create a setup script so you can simply run python setup.py –install.

As soon as I get the chance, I’ll complete the implementation and put together a command line client.  The program is released under the GPL.  Thanks go out to Mark for Dive Into Python and to the Python people for the excellent docs available online.