Thursday, May 31, 2007


For Feisty, just to learn something new, I thought I'd try Kubuntu (KDE Ubuntu) instead of Ubuntu this time around.

And... and... I think I'm a believer.

For what I've done so far, the extra information KDE provides is very well thought-out, just what I need to know when I need to know it. For instance...
  • When I want to remove a USB drive or somesuch, but something is still using it, Ubuntu (like Windows, including Vista) only tells me that something is using it. Kubuntu tells me what is using it.
  • Alt-Tabbing through my open windows gives more information than just the icon of each running program - enough so that I can distinguish between my eight different command prompt windows.
  • Hovering over an icon pops up the file properties. Nice! I mean, why else would I be hovering over an icon, except that I was fumbling for the right-mouse button so I could find out more?
  • Clicking my networking icon provides all the information I need to choose at a single glance, and then one more click connects me. Also, Kubuntu seems to jump to conclusions and do the right thing for networking - when there's only one wireless network around, Kubuntu just connects me without waiting to be asked.
The downsides I've found so far...
  • I really liked Ctrl-+ to increase the font size of GNOME windows. That's important when trying to read laptop screens in adverse environments (like outside). I haven't found a KDE equivalent.
  • The built-in text editor, Kate, bungles the spaces/tabs in Python files. That's one good reason to install Komodo (free editor or the real thing) immediately.
Real gurus can discuss the relative strengths of KDE and Gnome for hours, of course, and I thank God that I've never been caught in such a debate. I'm just saying that KDE is making a really good first impression on me, and that's after years of Gnome experience.

Friday, May 11, 2007

Extensible CheckBox List

Introducing a brand-new widget for TurboGears: Extensible CheckBox List!

To use it:
  1. easy_install xcbl
  2. In your,
    from xcbl.widgets import ExtensibleCheckBoxList
  3. In your form's WidgetsList,
    pets = ExtensibleCheckBoxList(options=['cats','dogs','turtles'])
    (exactly the same as you would for an ordinary CheckBox List widget)
The result - a CheckBox List with an "other" field that lets the user hand-enter new options - as many as they want.

Unfortunately, the new items will appear beneath the "Other:" box, not above it, unless you upgrade your MochiKit to 1.4. Details on how to do that and more are here.

Developing it was lots of fun - it really shows how easily a relative amateur can contribute to TurboGears. I hope to write up a "Developing and Contributing TurboGears Widgets for Dummies" document soon, based on the experience.

cleansing table and column names

What kind of joker thought "BASE POC'S" would make a good column name? Sheesh, MS Access. (Not to mention apostrophe abuse. See Bob's Quick Guide to the Apostrophe, You Idiots.)

To my surprise, I googled "script rename invalid columns oracle" and got nothing useful. So here's a chance to play with Oracle regular expressions.

You may be thinking, "If they're illegal column names, how can they get in the database in the first place?" With "quotation marks", that's how. In fact, you can
CREATE TABLE "!!!My Rockin' Table!!!"
( "*^@(@ @!!!" VARCHAR2(30)
"miXiNG CASE is TEH KEWList" VARCHAR2(30) );
and, not only will all your hideous names be used verbatim, but they will be case-sensitive. If you take advantage of this feature, you should be slapped. I guess the reason Oracle makes this possible in the first place is so that an import can be accepted from a source - like MS Access - regardless of how awful its names are.

Anyway, here's a PL/SQL cure for bad table and column names.
(link to code)
Renames tables and columns to be Oracle-legal.

SET LINESIZE 200 before running to avoid unwanted page breaks.
Run from an account with privileges to
- access v$reserved words
- alter the appropriate tables

Thanks to Eddie Awad for his description of v$reserved words:

Catherine Devlin,, 11 May 2007, v0.1
new_obj_name VARCHAR2(30);
CURSOR tbl_names IS
SELECT owner,
FROM all_tables
WHERE dropped = 'NO';
CURSOR col_names IS
SELECT owner,
FROM all_tab_columns
JOIN all_tables USING (table_name, owner)
WHERE dropped = 'NO';

DBMS_OUTPUT.PUT_LINE(this || ';');
-- Uncomment if you're feeling decisive
END do;
FUNCTION legalize(name IN VARCHAR2, replacement_letter IN VARCHAR2)
RETURN varchar2
new_name VARCHAR2(30);
is_reserved NUMBER(11,0);
-- must begin with a letter
new_name := REGEXP_REPLACE(name,'^[^[:alpha:]]',replacement_letter);
-- and contain only letters, numbers, #,_,$
new_name := REGEXP_REPLACE(new_name,'[^[:alnum:]#_$]','_');
-- and mixing case is evil
new_name := UPPER(new_name);
-- and we must respect Oracle reserved words
SELECT count(*)
INTO is_reserved
FROM v$reserved_words
WHERE keyword=new_name
AND (reserved='Y' OR res_semi='Y');
IF is_reserved > 0
new_name := SUBSTR(new_name, 1, 29) || '_';
RETURN new_name;
END legalize;
DBMS_OUTPUT.PUT_LINE('set scan off');
FOR col IN col_names
new_obj_name := legalize(col.column_name, 'C');
IF new_obj_name != col.column_name
do('ALTER TABLE ' || col.owner ||
'."' || col.table_name ||
'" RENAME COLUMN "' || col.column_name ||
'" TO ' || new_obj_name);
FOR tbl IN tbl_names
new_obj_name := legalize(tbl.table_name, 'T');
IF new_obj_name != tbl.table_name
do('ALTER TABLE ' || tbl.owner ||
'."' || tbl.table_name ||
'" RENAME TO ' || new_obj_name);
END cleanse_names;

Larry Wall, God, Lois McMaster Bujold

Part of what got me thinking about my last post is that I'm suffering a little crisis over Larry Wall. I'm really admiring his spirit. For instance, I like his way of expressing his Christianity.

As if that weren't enough, he's into The Lois, as quoted here:
Note how we still periodically hear the phrase "serious literature". This is literature that is supposedly about Real Life. Let me tell you something. The most serious literature I've ever read is by Lois McMaster Bujold. Any of you read her? It's also the funniest literature I've ever read. It's also space opera. "Genre fiction," sneers the Modernist. Meaning it follows certain conventions. So what? Nobody in the world can mix gravity and levity the way Bujold does in her Vorkosigan books. It's oh so definitely about real life. So what if it follows space opera conventions. Sonnets follow certain conventions too, but I don't see them getting sneered at much these days. Certainly they were always called "serious".

How long till Bujold becomes required reading in high school? Far too long, in my opinion. Horrors. We wouldn't want our students actually enjoying what they read. It's not--it's not Real Life.

As if the Lord of the Flies is real life. Feh.
Yes, I'm a Lois fan, too. I once drove hundreds of miles to an SF con purely because she would be there...

So, anyway. Yaaaay, Larry. But there's no getting around this: I prefer Python. Perl is great, Ruby is great - all dynamic languages contribute to each others' success, I think, because the prominence and respect won by each rubs off the others, so we can get our necktie-level blessing. But, when it comes down to what I use, I can't write anything else these days without wishing it were Python.

Tuesday, May 08, 2007

getting a bit philosophical

Have you had the experience of struggling with a problem for hours, going to ask for help with it, and then realizing the answer to the problem while you're in the middle of asking the question?

Of course you have. It's an amazing phenomenon. It really shows how much the brain depends on language to think clearly. It's one reason I'm such a junkie for user groups and conferences! And it's not good enough to just hear it or read it - you have to speak it or write it to really engage your brain. Similarly, sometimes it seems like you never really understand a subject until you have to teach it to somebody else.

Meanwhile, it's become an axiom of conversational politeness that politics and religion are to be avoided in most contexts. Which means... which means that we're forbidding ourselves to use our most powerful means of stimulating clear thought... for some of the most important ideas we have to think about. Hmm...

Wednesday, May 02, 2007


As I work more on the Geek Event Aggregator and similar projects, I'm getting really fascinated by movements like microformats and POSH - efforts to make web content more semantically meaningful and machine-readable, without trying to radically reinvent the web. Just small tweaks to the HTML we've been writing all along can make a world of difference - indeed, often just using HTML best practices that have been around (and largely ignored) forever. Interesting stuff! I'll probably be blogging about it more in the future.

One related concept is blogchalking, so here goes.
This is my new blogchalk:
United States, Ohio, Dayton, Brookville, English, German, Catherine, Female, 31-35, Python, environment. :)
That's for machines to read. Humans, avert your eyes.

Let's see, I have about three more months before I have to update that age category.