A Twisty Turny Thing

The BlackAdder quote in full is “You twist and turn like a … twisty-turny thing”, and I refer to the interesting contortions through which PythonWin goes in it’s admittedly impressive attempts to be an IDE written in the same language that it supports. I’ve spent a fair amount of time in PythonWin over the last couple of weeks (when I say in, I mean interacting with it, not poring over the source code like Gandalf looking to identify the Ring[1]), using it to develop a crafty little system that generates questions from a database of “facts”[2]. It’s the sort of batch process that, once kicked off, runs overnight, using around three thousand input records to generate several thousand output ones. Most of the heavy lifting happens in Python, which builds up networks of object to represent the datums and relationships therebetween. It’s cool, and pretty memory-intensive.

So a lot of the think-write-read-run-debug cycle is done via PythonWin and, let me tell you, that little near-the-taskbar icon that lets you drop into running code is a blessing from whatever Gods watch over programmers. I remember missing the sublimely simple tactile trigger of Control-C when I first started using Windows (in those days I was more a VMS and Unix type of lifeform), the ability to, in effect, say “Oi! Program! No!” whenever one ran amuck. Windows doesn’t give you that. You can, of course, try the little Fisher-Price “X” icon. Which sends the application a polite event to ask it, if it wouldn’t mind, to be ever so terribly helpful and close. PythonWin in full flow doesn’t respond, and not unreasonably so. You can then try the right-click-on-the-taskbar-wotsit, which tends to be doubly frustrating, since the menu pops up and down like… well, I’ll let you supply your appropiate humourous metaphor here. Again, the Close option doesn’t so much close as not. One yearns for the power of Control-C as one gives the three-finger-salute and conjures up Task Manager like some Demon from the nethermost slums of Pandemonium and commands it to End Process.

Or you can blithely click on the little coiled green snakey thing in the area of the screen that is apparently not called the System Tray really and choose to Break Into Running Code. I like that; there’s a certain burglariousness about it, and it’s satisfying to see the same old command-line-esque KeyboardInterrupt exception launched (I like to imagine) on a ballistic course to crash through the thicket of namespaces and pin the interpreter, writing and flailing, to the ground.

Anyway, none of this is the fault of PythonWin, which is really dead dead clever, but is written in Python. And thus contains the seeds of its own weakness, for occasionally, after Breaking Into that Running Code, a fountain of traceback bursts onto the interactive window (that’s the window inside the PythonWin window, not the PythonWin window itself, which is a container window for the other window, to be clear) and after that, all bets are off. Now clicking the X or choosing to Close will result in just another traceback, and another, one per click. The Window That Would Not Die. For, of course, as well as my code running, PythonWin itself is also running, so that KeyboardInterrupt missile is as likely to clobber the one as the other.

But I do like PythonWin, genuinely I do.

[1] You can assume from this that, like many other LOTR fans, I celebrated the release of The Return Of The King by watching the whole lot over several evenings. Let joy be unconfined.
[2] As per usual, I omit the identifying details of what I’m actually working on because, hey, I signed NDAs too, you know.

Decreasing Values Of Addition

…or how added value gets smaller.

I run ActiveState’s ActivePython on this ‘ere XP laptop. It’s quite a nice package, has the documentation in a nice indexed Windows help format, works under cygwin, etc, etc. And here Python 2.3.4 comes out. Now, call me picky, paranoid or just plain pedantic, but I like to keep all the Python installations on the three main machines I work on in sync. That’s the XP laptop, the Linux server at work and the Linux gateway/server at home. I’ve had annoying little issues in the past when using Python 2 under Windows/cygwin to develop locally and then moving to an older Python on Linux. RedHat used 1.5.2 for a lot of their setup scripts and it took me a while to bite the bullet, blow away the RPM and go for a proper Python 2 install (with all the files dropped into the same locations as the older Python, natch).

So on Linux it’s the same ole wget / tar / cd / configure / make dance as it ever was, subject to remembering exactly what set of exotic configure options I used last time (hint to self, never delete config.status). But on Windows, ActiveState are now a couple of Python releases behind, so what do I do? Of course, I can download the Windows release from python.org, but then I need to think – what will I lose by replacing ActiveState?

The considerations are – what added value have ActiveState given me in their own distribution? And have they, by providing me with an ever-so-convenient one-click .msi file, locked me into using them from now on? Hmm… this is not such a clear tradeoff as I thought.

As it happens, the Python.org installation picks up the right install directory and neatly replaces the ActiveState stuff anyway, so it’s not that key a question. But for a moment there…

It Was Coughing Up Blood Last Night

I invested an hour on Wednesday in replacing the oldest hard drive in the server at home with a new 80Gb one. First time I’ve bought a disk from Amazon; well, actually one of their small army of independent sellers. Better price than DABS or MicroWarehouse, with one-click buy and cheap delivery. What’s not to like?

Amazon get so much so right that they’re becoming annoying. Like Tesco (for UK readers), they’ll end up owning the entire retail marketplace; anything that can conceivably be bought online will be available from Amazon. It’ll be cars next, or white goods.

Anyway, back to the subject of drive replacment; if I hadn’t bothered to go into the depths of Computer Management and poke about in Disk Management, I wouldn’t have seen the little yellow triangles on the C and D drives. Nor would I have noted the several I/O Errors that an investigation into the Event Viewer showed up. What is it about Windows that makes it pop up so many annoying announcements that I don’t need (No, leave my Unused Desktop Icons alone!) and hide useful information that I do? Where’s my lil’ popup balloon saying “One of your disk drives is reporting that it may fail?”. Damn Microsoft and their Fisher-Price computing.

Contrariwise, the Linux gateway server emailed me to tell me it was low on logfile space, me having misremembered to add an apache log to logrotate. Nice computer.

A Hundred Musts And A Should Or Two

So three and half hours of establishing project requirements later…
There are only a few sorts of meeting.
The first sort is where ThoseWhoCommand seek to provide guidance/orders/information (strike out those that do not apply) to ThoseWhoObey. Try to avoid these.
The second sort is where people (usually male) who aspire to be ThoseWhoCommand from OrganizationA meet their counterparts from OrganizationB. These can be interesting to the abstracted observer who can see examples of human territorial and pecking-order establishing behaviour in the wild, as the various players “tomcat around” each other. Listen to the stories of battles won and lost, and smell the virtual scent of boundary-marking urine.
The third sort is where ThoseWhoDo (a disjoint set, ideally, from either ThoseWhoCommand and ThoseWhoObey) get together to work out how something worth doing is best done. These are good meetings. Yesterday’s was one of these.
Out of it will pour a veritable waterfall of established Things that the application Must Do, together with a smaller number of Things that it Should Do. There will also be some Things that are NiceToHave. It’s inevitable that some of these will fall by the wayside during the long, hard journey of Development to the Mount Doom of Product Release. Mourn for them in advance, for there will be no time later on.

Zone Alarm Is Silent

That’s odd – if you try to make a VPN connection (using GRE) when you have the otherwise-quite-good free ZoneAlarm installed… the connection just fails. SIlently. None of those little ZA popup things that one gets so accustomed to seeing. Turns out you have to add the target host as a trusted entry in the Firewall Zones. But it took Google to find that out.

First We Have Naming Of Parts

So it’s 12:30. So in half an hour (media hora) I zoom off through the Cheshire lanes to the kickoff requirements setting meeting for ThePhoneProject. This would be slightly easier if we actually had the contract signed, but it’s arrived in the inbox around an hour ago and is still the subject of debate. Maybe I’ll end up signing it and handing it over at the start; nothing like hitting the ground running.
It’s a fun project, or promises to be, with a bunch of C++ development of a phone app (which someone else is doing and I’m managing) and a significant amount of Zope/Python code (which I’m doing and also managing). Pressure’s high, expectations ditto. But hey, if life was boring, it’d be, erm, more boring.
As it is, it’s a lovely spring/summer day, and I have a half hour drive through the countryside from home to the meeting. The One True Joy of working the way I do is that I can appreciate where I live because I spend so much time here. The laptop in the study, or in the dining room with the patio doors open to the garden (wireless networking is my friend), or even, sunlight permitting, in the garden. Yes, it’s all down to me and if I screw up there’s nobody else to help, but then every job has pros and cons.
I also get half an hour each way (there and back) to do another Spanish lesson. Which is pretty pointless in every sense other than being interesting. My father, being the sort of annoying intellectual who accomplishes six impossible things before breakfast daily, speaks German, French and more than a smattering of Dutch and those Scandinavian languages that look like German and sound like Gaelic. Hence tackling German and French is the sort of proactive career move that would be squarely on his turf. Spanish isn’t, so hoorah for the power of the CD burner and two more half-hour doses of Pimsleur’s Spanish II.

So beginnt es

Hum. So here we are switching blogging platforms again. No matter, it’s something that comes to us all, I guess.
The story so far… Our hero faces the twin challenges of handling the questions and database for a PlayStation game whilst, simultaneously, trying to get a Zope-based website set up and running to support a consumer product launch. All whilst juggling pricess eggs in variable gravity (pace Larry Niven).
Any endeavour of this magnitude requires the proper journalling of the insights, discoveries and plain ole lessons-learned-from-screwing-up that are inevitably encountered. Hence the blog – let’s see if it dies the death of a thousand postponed entries that so many do, or thrives and prospers. Or somewhere in between.
Today’s discovery (well, yesterdays, as it happens) is that Zope has a nice little undocumented feature that damn well ought to be recorded somewhere. Consider – if you have a variable, let’s call it thingy that contains a path element, you can write a ZPT element like so:

<span tal:replace="myroot/?thingy/attribute"/>

and lo! you get the value of the variable substituted right into the path. So much nicer than doing

<span tal:replace="python:myroot[thingy]['attribute']"/>

or even

<span tal:replace="python:path('myroot/%s/attribute' % thingy)"/>

So why, you ask, is this little pearl not recorded anywhere that a novice in the ways of ZPT is ever likely to encounter it? Because Zope is one of those things that demonstrates both the extreme power and the essential weakness of open source (I know, I’m beginning to sound like the Architect in the Matrix now). The power, in that it’s a huge, powerfule and clever system that provides an extremely elegant and versatile way to build web applications. The weakness, in that the documentation, in the words that the Americans would use, “sucks like a Dyson on a three-phase supply”.
Well, okay, maybe it’s not that bad. There is The Zope Book, together with a whole bookmark-folder-full of hints and tips, but the documentation only generally comes in two flavours. These are:

  • Here’s A Walkthrough Example in which a guru shows a MoreOrLessContrived and DeliberatelySimple application and walks you, in tortuous detail, through creating it with Zope. The level of detail is such that any future version of Zope will probably look and behave differently enough that the screenshots and dialogs will require redoing. This is suitable for those in their first week or two of the infamous Zope learning curve.
  • Here’s A Deep And Obscure Point in which a guru speaks of complexities and mysteries buried so deep in the bowels of the source that one must be several months into the same learning curve.

    Don’t get me wrong here… I rather like Zope. In fact, I like it more the closer I get to it, but Sweet Mother Of Abraham Lincoln, getting to it is far harder than it ought to be.