Running simple SQL commands on the command line

January 8, 2005
2 comments Python

In my Zope usage I use a lot of SQL stored on the filesystem. These files contain DTML syntax and parameters like ZSQL Method objects inside the ZODB. Sometimes, to test the SQL code I have in these files I want to run it on the command line. To be able to do that I've written this little Python script which is placed in my ~/bin directory in Linux. It only works with PostgreSQL at the moment but people who like the idea and prefer Oracle or MySQL could probably find where to make their changes. (The psql -f command is the ticket)

Example foo.sql:


<params>id=1
name</params>
SELECT *
FROM sometable
WHERE id = <dtml-sqlvar id type="int">
AND   name = <dtml-sqlvar name type="string">

Which is run like this:


peterbe@trillian:~ $ rundotsql.py -U peterbe testdb foo.sql

Truncated! Read the rest by clicking the link below.

Infinitely deep illustration

December 26, 2004
1 comment Misc. links

deep-illustration.jpg I can guarantee that you'll be stunned by this illustration. It's a Flash animation and after some loading you'll be able to use the mouse to go deeper and deeper into the picture. I've never seen anything like this on the Internet before.

How do they do that? I'm curious. The picture is fuzzy but I still think a lot of attention has gone towards the details in the pictures. Salvadore Dali would probably enjoy this illustration if he was alive today.

Merry Christmas

December 22, 2004
0 comments

Today I'm going to Sweden to celebrate Christmas and new years. Sorry to you, my friends, for not sending any Christmas cards but check out this site for a good laugh.

The problem with CSS

December 21, 2004
1 comment Web development

CSS and web standards is a great tool for producing good web pages. It allows you to separate out content from presentation. The CSS file should be given a lot of responsibility and be very powerful in terms of what it can control.

The problem is that the CSS file can grow very big resulting in slow download times for the web surfer and heavy load on web servers. Usually it grows because you either:

  • add more HTML that needs to designed but later the HTML is removed/expired but you don't remove what was added to the CSS file
  • add more CSS to cover potential additions of HTML that never happen

Truncated! Read the rest by clicking the link below.

__call__ folderish Zope objects

December 19, 2004
0 comments Zope

I ran into trouble with a Zope class that inherits from OFS.Folder.Folder (the classic Folder class). My class is a bit special since it's acting both as a non-folderish document like object but still needs to contain other objects such as images and file attachments. The class had a method called index_html which looked something like this:


def index_html(self, REQUEST, **kw):
    """ return something"""
    return self.something

The problem was that if I create one of these instances with the id index_html it simply could not be viewed.

Truncated! Read the rest by clicking the link below.

Ugliest site of the month, plus44.com

December 17, 2004
2 comments Web development

8 random pages from plus44.com I actually feel bad about complaining about this website because it's a vast bank of information about England written by a single person called Philip Davidson. According to his website, he's composed some 3000 pages! I guess all have been done with state of the art Microsoft Frontpage 0.1, MS Paint and Netscape 2.0.

The reason I genuinely dislike looking at this website is that all pages seem to be very different. There's not consistency and you constantly fear that you've left the site without noticing it. A quick glance on the URL before you panic assures you you can remove the cursor from the back button. The front page has five animations inclusive an animated background that can probably cause damage to your eyes. Be careful!

The site also features frames that scroll forever and hides parts of the navigation. On this page there's a picture which is the word "RETURN"; next to it is an explanation what that says you can press it to return to the main page. What's the point then of having the image if you have to explain it? On some pages there's a nav at the bottom with the headline: "Transfer to:". Since when do you transfer between different pages on one site? Some pages surprisingly open new windows with no apparent reason. Be careful!

Python package path when executed elsewhere

December 14, 2004
3 comments Python

I stumbled across a problem today with running a python package from a different directory than where the python files are. The package looked like this (in principle):


/home/someone/mypackage/
   __init__.py
   template.html
   foobar.py

The foobar.py script contains this code:


def foo():
   tmpl = open('template.html').read()
   return tmpl.replace('X','Y')

That's fine and works when you run the file directly. The problem comes when you run the foobar.py script from somewhere completely different (e.g. /home/mrbloggs/otherpackage/). The solution to this comes from Zope's package_home.

Truncated! Read the rest by clicking the link below.

Do you know what safe txt is?

December 10, 2004
0 comments Misc. links

MOBi gives some amusing advice on their FAQ about safe TXT.

"What is safe TXT?
By giving out your MOBi rather that your mobile number you are practicing safe TXT."

It's actually quite a nouvelle thing. MOBi thus makes it possible to use SMS texting but without a mobile phone number. This of course suits small businesses very well because any mobile phone inside a company belongs to a person; not the company. MOBi will then make it possible to have an SMS face outwards towards its customers.

Truncated! Read the rest by clicking the link below.