Ian Bicking: the old part of his blog

Little modules

I've added a few small modules to my Subversion repository, and generally tried to clean it all up. They are located at svn://colorstudy.com/home/ianb/ or http://colorstudy.com/svn/home/ianb. Here's description of them all:

A module used as DirectoryIndex in Apache. Creates a somewhat better index than the default in Apache. Makes thumbnails of images.
A module to keep my audio files well sorted. It moves files around according to the metadata, or changes the metadata according to the filename. And downsamples my oggs to mp3's. It's rough, but it's useful for me.
Parses .ini files. There's been discussions about a replacement for ConfigParser, and this fits into that.
A Javascript slideshow which I mentioned before. I think it works properly in IE now.
A color module, RGBA, etc. Doesn't actually offer many features at this point.
Pretty prints the difference between two dictionaries. I've used it in unit tests.
recipes.html and recipes.htmlstream
Two modules for generating HTML. html is just a simplest-possible-thing generator, similar to stan or HTMLgen.

htmlstream is a bit more complex, and knows about the structure of HTML. So it kind of validates your HTML as you go along. Unlike html and similar modules, it implements a stream, so you don't have to have valid HTML at all points in your module. Here's an example of creating a SELECT with both html and htmlstream:

select_name = 'month'
data = [(1, 'Jan'), (2, 'Feb'), ...]

from html import html
ops = []
for value, desc in data:
    ops.append(html.option(value=value, c=desc))
select = html.select(name=select_name, c=ops)

from htmlstream import HTMLStream
s = HTMLStream()
for value, desc in data:
    s.option(value=value, c=desc)
select = s.finish()
Generates values for use in HTML hidden fields, signed so that the user cannot modify the value (e.g., using this bookmarklet).
Mentioned this before; kind of a read-only attribute.
From SQLObject, this allows you to make SQL queries using Python syntax.
A descriptor (like setonce) that enforces the type of the attribute.
From FormEncode, this unpacks variables from an HTTP request into a nested structure. While all the names in an HTTP request are flat, but using . and - this will change it into a bunch of nested lists and dictionaries.
Created 22 Oct '04
Modified 14 Dec '04


Hi, Ian.

I had to change line 67 to make indexer.cgi work for me (Apache, running as CGI from .htaccess):

#path_url = os.environ['SCRIPT_URL']
path_url = os.environ['REQUEST_URI']

There was no SCRIPT_URL key. Other than that, works great. :)
# Roberto

On my system it must be SCRIPT_URL or it won't work
# Dagur

I concur with Roberto, REQUEST_URI works for me; SCRIPT_URL does not. I'm using Apache 2.
# Jim

Re: the slideshow, I have some Javascript code that does something along similar lines, paging backwards and forwards between sections of text. It animates fairly nicely, too. You can see it in action here:


The Javascript source files can be seen here:

# Dominic Fox

Funny, no SCRIPT_URL? I'm running it under Apache 1.3. I also can't figure out how to really tell what directory the indexer is supposed to be indexing; instead I have to fake it, and it might not work with aliases and whatnot. Which seems like an oversight on Apache's part. Maybe some of this is changed in Apache 2.
# Ian Bicking

I am using Apache 2.0 btw.
# Dagur

I'm using Apache 2 also, but with a few hacks for my Pyblosxom setup that could be the culprit.
# Roberto

sqlbuilder wants to import a non-existent 'converters', which is presumably in the original sqlobject.
# Hamish Lawson