« December 2006 | Main | February 2007 »

January 25, 2007

Sawing off the handle

Fantastic comment on this excellent blog post:

Some people I know saw off the handle of their toothbrush when they go mountain trekking. It sames about one gram of weight and makes brushing your teeth so much more tedious.

The same goes for removing the explicit self. It saws off a small weight, but every time your mind needs to examine some code, it will have to generate that self, making the job more tedious.

The original post is worth reading — language bigotry, like all bigotry, is easy to fall into, but it’s bad thinking. Don’t do it kids.

Using TextIndexNG3 with Archetypes and automated testing

I'm currently working on the latest version of our Business Directory product for Business Link Kent (it should be going live on 8th Feb, in fact).

Because of the complex searching requirements plain old ZCTextIndex or TextIndex just aren't enough, and we've incorporated the very powerful TextIndexNG3 instead.

Unfortunately the installation documentation and so on doesn't really deal with implementing new indexes using the product. Nor does it show how to programatically convert the pre-existing indexes upon installation of your product; instead it is described as manual steps.

Manual steps do not play nice with either our automated testing strategy or the fact that we blow away and rebuild our development environments 3 or 4 times a day.

In your Install.py (yes, this is a Plone 2.1 site and no, I'm not using Generic Setup for this one) put the following function (I'm using stemming here, so don't copy this blindly if you don't want the effects of stemming):

Then call updateIndexes(out) from your install method and lo! your indexes are converted by your install script, rather than having to do it manually each time.

To implement new TextIndexNG3 indexes from within your Archetypes schema definition is very simple. I'm still debating whether I should be making use of the broader ability of TextIndexNG3 to search across a subset of the fields that it indexes (meaning that I might not need to create multiple TextIndexNG3 indexes), but for right now I'm going the simple route and defining them on the schema as I would for any other type of index.

Once you've installed TextIndexNG3 have a look at Products/TextIndexNG3/src/config.py. In there are all the parameters that you can pass at the point of index creation. To do this in Archetypes it's exactly the same as it would be for any other index; any non-default creation parameters should be comma separated after the index type is specified. For example:

So far the product looks very powerful, and it's definitely sorted all my complex searching requirements (ranges, booleans and so forth) that until now had me completely stumped.

January 09, 2007

Chandler, and the hardness of software

CIO Insight magazine have a good interview with Scott Rosenberg, who was involved in the Chandler project. In many ways it seems to me like a poster-boy for the Agile movement. If Chandler had been approached in a more agile manner they may not only have shipping code, but I think the shipping code would be, now, for a very different piece of software.

Chandler made quite a splash when the project was launched because the project lead was Mitch Kapoor; creator of Lotus 1-2-3, Notes and the ill-fated but ambitious Groovy, and one of the leading lights in software development. One of the key things in an open source project is the project lead and Mitch is a proper heavyweight. He attracted a lot of very good developers and the project got moving with quite a fanfare.

I remember when the Chandler project was announced. Back then it was a fantastic idea, although ambitious. I still think the idea has a lot of legs. The idea was to produce a Microsoft Outlook killer, but using good UI and engineering design techniques. If you analyse it, Outlook is a pretty terrible application. Most of its users have probably never even thought about it, but the application only barely satisfies common use cases, and those with a lot of laborious work on the part of the user. It is all most people have used though, and people tend not to be terribly introspective about their software.

Mozilla Thunderbird is just as bad, and even less ambitious than Outlook. As an email client, neither of them compares at all well with the power and features of mutt, for example. Mutt however takes ages to learn and is ultimately limited by the capabilities of a terminal.

So, Chandler was supposed to change all this. Bring the sensibilities of a spreadsheet (i.e. a thinly disguised programming environment) to Groupware. To be a Notes for the 21st Century. Satisfy the Real Needs of Groupware users.

This is a Hard Problem. It has all the features of a project that disappears up its own arse, just as Mozilla did. There is a huge scope for architecture with such a large problem, and so that’s what they did: Architecture. Just as Mozilla did. Even though they sensibly chose Python to develop Chandler (unlike C and the homegrown XUL for Mozilla), they indulged in huge amounts of Big Design Up Front, which means that the environment and probably the users are now well ahead of where Chandler was aiming.

Maybe, like the Mozilla project, it will suddenly emerge from obscurity to take over the world. They will have a much more difficult environment for launch than Mozilla did however. The browser incumbent, Internet Explorer, was so appallingly bad it made a very easy target. The incumbents for Chandler will not only be better but will be hosted, browser accessed applications — which provides a set of behaviours that Chandler will find it impossible to replicate.

All of this may not sound like a software problem, but instead a marketing problem. To call it that is to miss much of the point in the real difficulty in software development. The most intractable problem is not avoiding building buggy software. The problem is in building the software that people actually want.

January 08, 2007

Archetypes validation on the basis of the value of more than one field

In the general category of 'you learn something new every day'.... Today I'm back using Plone (it's been a while!). I'm trying to validate a particular field on the basis of the value of another. Specifically I'm trying to validate a postcode depending on the selected country (so use different validators depending on the country the user has chosen).

If you use Archetypes validators it initially appears as if you are passed the entire object as well as the new value (kwargs['instance']), but unfortunately the validator is called 3 times, and the first two calls have the changed value that you're trying to validate, but the unchanged object. What that means is if the user changed the postcode and the country in the same edit the validator would be using the wrong country on the first call, and raise an error.

Some digging around led me to this reference on the plone site which describes how to correctly validate across multiple fields. Instead of registering a validator as usual, define a pre_validation or post_validation method on your object, pull the values that you need from the REQUEST object, perform your validation as required and write any errors to the errors object. It's not quite as elegant as the general validation machinery, but it certainly does the job.

January 03, 2007

Play nice everybody

As community sites become the me too of 2007, with businesses all feeling that they need a slice of that user generated content goodness, there are going to be some rocky times ahead. It's worth remembering that even in the best run communities a reasonable proportion of the users will misbehave (at least according to the rest of the group). When your site is brand-dedicated-me-too with a veneer of user focus on top rather than truly user centric it's likely that the problems will get worse more quickly as your initial well meaning user base is forced out by hijackers simply looking for a place to hang out.

Moderation will be key (third party services like eModeration can help, for example), but it's worth remembering to plan for the worst kinds of behavior from your users from the start.