Python Programming, news on the Voidspace Python Projects and all things techie.
User Plugin for rest2web
The first user plugin has been written for rest2web.
That's not bad considering I've not settled the API.
It's actually an interesting plugin, by a chap called Paul Bartlett. He's created a Source Code Highlighting Plugin, it works for multiple languages (unlike the standard macro one) by using an external php script. It also adds a link to the code to download. Nice.
rest2web is slowly finding more users. I mainly develop it for Voidspace, but it's nice to see it being useful for other people.
Yahoo Maps and Python
this is probably old news - but I've never heard it. I stumbled across Yahoo Maps today (ironically enough via Google). The URL is :
Notice the prominence of py in the URL. Looks like yahoo are using Python for (at least part of) their mapping software. Nice !
Best of the Blog
I've just added a new page - Best of the Blog.
It contains links to the better (or longer) posts that I've made on this blog. As you might imagine, it's quite short !
Categories: Blog on Blogging
There has been extensive discussion on the subject at comp.lang.python. It seems like a lot of people want an Ordered Dictionary, or have opinions about what it ought to do.
As a result of this discussion, Nicola and I are going to make changes and improvements to the odict module.
These include :
Adding sequence methods like :
Performance improvements on creating an instance
Hiding the sequence attribute and providing access to it through the keys and values methods. (Including allowing you to set them, by passing a sequence to these methods)
Possible alternative implementations (probably simple sub-classes), for use-cases other than "key ordering by insertion time"
This last change will break backwards compatibility. Any objections should be raised now, before it's too late.
At some point I will have to decide whether to make (all of) the same changes to ConfigObj, which is also (effectively) an ordered dictionary.
It's worth pointing out (as illustrated by Fredrik Lundh) that an ordered dictionary is mainly a convenience object. (Although damn convenient). You can usually get better performance on the same data structure by using a list of tuples, and passing it to dict when you want to access members by key. The resulting code is less readable though, IMHO.
That could be resolved by an implementation in C, or by waiting for PyPy, upon which pure Python implementations are secretly hoped to run faster than C.
Click Thru for Me
I use two good services that have affiliate programs. I haven't earned anything from either (yet) - but they're both good services, so worth referring people to.
The first is my virtual host provider. They're called Tektonic and offer cheap virtual hosting accounts (with root access). This is a great way of playing with a dedicated server, without the expense.
I've had no noticeable downtime with these guys, and their tech support is very good. If you're prepared to install your own server - or have someone else do it for you - it's an easy way to get a hosting account that allows you to play around with all the fancy new web frameworks we're seeing.
The second is cheap usenet access from Teranews.
The free service (which I use) actually costs $4 to open the account and gives you 50mb of nntp access per day. Access is very fast, and they carry all the binary groups. They have a range of other packages as well.
If either of these services appeal to you, you might as well go through my affiliate links.
Reply-To Considered *Damn* Useful
It annoys me that most Sourceforge mailing lists (and some other lists that use mailman) don't set Reply-To back to the list.
This is (I guess) a long running debate. This is my reply to the summary points in Reply-To Considered Harmful.
It violates the principle of minimal munging.
Practicality beats purity. 
It provides no benefit to the user of a reasonable mailer.
This isn't true. I use Thunderbird, and unless I'm missing an obvious option somewhere, I always have to choose between manually copy and pasting the list address, or using Reply-All and deleting the original sender (to only reply to the list).
It looks like he is defining any reasonable mailer as Elm.
It limits a subscriber's freedom to choose how he or she will direct a response.
Not true - all reasonable mailers preserve the original from address as part of the email.
All reasonable list managers do too. Why should most of us (the most of us who don't use the one true mailer) suffer because of the occasional, badly designed list manager.
It actually reduces functionality for the user of a reasonable mailer.
Not true. The original from address is still preserved - as above. (So there need be no reduction in functionality).
It removes important information, which can make it impossible to get back to the message sender.
It penalizes the person with a reasonable mailer in order to coddle those running brain-dead software.
His base premise is that in a reasonable mailer, munging reply-to risks losing the original From information.
This means that because you have the option to hit Reply-All if you want to reply to the list as well, it's better not to mung.
This assumes you're happy to send two copies to the original sender (one from the list as well). I've also never seen a reasonable mailer which loses the information in question.
90% (or more) of the time I want to reply 'On-List'.
If his reasonable mailer really does make it harder to reply to the sender, with emails munged in this way, maybe his mailer is at fault.
It violates the principle of least work because complicates the procedure for replying to messages.
See above - the principle of least work damages his argument.
It violates the principle of least surprise because it changes the way a mailer works.
Nonsense. The message is from the list, so least surprise is to reply to the list.
It violates the principle of least damage, and it encourages a failure mode that can be extremely embarrassing -- or worse.
Unless there are negative consequences of not replying to the list. (Email doesn't reach a large proportion of intended and expected recipients).
The normal way to reply to an email is to use the Reply button. Not using the Reply-To feature breaks the standard behaviour - which is annoying and awkward, and more likely to result in failure.
Your subscribers don't want you to do it. Or, at least the ones who have bothered to read the docs for their mailer don't want you to do it.
Moot point. Breaking the expected behaviour of the standard email client, makes it annoying to use lists configured in this way. I think subscribers do want it... Except pretentious ones who use Elm. 
Anyway, rant over.
|||This is the most valid point he makes, actually.|
|||I have nothing against Elm users, except the pretentious ones...|
Website Updates with rest2web
The updates are made much easier by rest2web. For those who are interested in a site building tool, but still don't understand what rest2web has to offer, here's a brief example.
A website is divided into directories, each directory has an index page and several individual pages - all of which are stored as text files.
The individual pages (articles) can be stored in reST format, which is much easier to maintain (although you can also use HTML if you want - I could support alternative markup formats if anyone wanted them). The generated pages are all inserted into an HTML template.
Each page starts with a small piece of metadata that describes the page. A typical one might be :
restindex target: ../gibson_disney.shtml crumb: Disney tags: cyberpunk, gibson, article, disney, singapore, travel section: articles page-description: An unusual article by William Gibson... on a visit to Singapore. /description /restindex
Most of these are optional.
The article in each directory can be divided into several sections. This makes the index page clearer.
The nice thing is, that the metadata for the pages in a directory are in the pages themselves. The index page is passed all the metadata when it is created.
You can build most of the index page with something like the following snippet of code :
print '<div class="indexblock">'
title = '''
%s''' % (section['title'], section['description'])
print_details(section, split=False, page_title=title)
It's easier to show you the results than to explain the details. Have a look at the Cyberpunk Index Page.
rest2web uses the metadata - plus a title and description of each section in the index page metadata - to build the index page. You can also specify the order that pages appear in each section. Nice hey.
This work is licensed under a Creative Commons Attribution-Share Alike 2.0 License.