JS Fireworks – in SVG

I’ve taken another look at last year’s Chrome Experiment, JS Fireworks.

This time I’ve rewritten it to use SVG, whose arrival in IE9 promises to make HTML more interesting. In fact, I’m far more excited about animated SVG than CSS transforms and the fabled HTML5.

I used Keith Wood’s jQuery SVG library, which seems quite helpful, and simply replaced the ‘draw line’ commands with their equivalents.

Canvas is the bitmap to SVG’s vector, so while I have to clear the screen and redraw each time in canvas, I merely need to move the lines in SVG. Presumably the number of shapes on screen affects performance, so that was a big difference.

Here’s the result: JS-Fireworks in SVG. I’ve reduced the number of items in each explosion from 30 down to 10. You’ll see why.

It runs very quickly in Chrome (Mac), slowly in FireFox, and smoothly, though not excessively quickly, in IE9, which I’m quite excited about. Where’s IE9 Experiments?

I haven’t tried IE678. But then I haven’t tried Mosaic either.

aitch-tee-tee-pee colon slash slash

It’s lovely to see someone stand up and take the blame for a mistake they’ve made. I’m not talking about the Government (obviously), I’m talking Tim Berners-Lee, inventor of the World-Wide Web. He’s come out and apologised for the redundant slashes that appear in every web address (url).

Good man. But what of the rest? The “www.” that was so unpronounceable is already obsolete, and personally I think twitter can take credit for popularising the contemporary non-dubbed url form. Boffins in lab coats has worked tirelessly to make memory ubiquitous and cheap, but we’ve just stuck some character limits in there to be fashionable or something. Hey ho. But the “www” is gone.

Can anyone tell me why there’s a huhtetep, “http:”, still shown in my address bar? What’s it for? What does it tell me? I don’t actually have to type it in these days, but it appears there anyway. Why?

Is it to show that I’m looking at a document provided by HyperText Transfer Protocol? I don’t care about that!

Is it to show that I *could* be looking at an FTP site, using the same browser? Ok, fair call, but that’s so rare to do so, that you could default to not showing “http:”, and then only show “ftp:” when FTP sites are used. It’s not like every browser has a built-in FTP client anyway. Same goes for local files.

Is it to show the “s” when I look at an “https” page, meaning that the connection between my browser and the website is encrypted? Well, ok, but what was wrong with the padlock? Why is there such a strong connection between certificates and https anyway? They mean completely different things. I don’t need a certificate to know gmail.com is Google. Equally, a certificate costs about 20 bucks and has so few checks that I’m hardly reassured when dealing with a new site by the presence of the certificate. What I want to see is a padlock. Drop the “https” and show me a padlock.

Is it for future extensibility, to enable a future Internet to use new and unusual protocols? Like “about:”? Again, it would be simple enough to recognise a default of http. If you go to about:config, then display the protocol. Why is this hard? If a new protocol came along to overtake http, then I think a bigger browser update would be needed anyway.

I think browser manufacturers should take treat it like the port. Every web page is served by a port, and for most of the web, that’s port 80. You could look at this website by typing http://kenneth.kufluk.com:80. But mostly, the 80 is assumed. You only ever type in a port if you’re not using port 80, such as for local development. If you type “:80” into a web browser like Chrome, it disappears. Let’s do that for “http://” as well. if you’re thinking there might be confusion between ports and protocols, you’re wrong. Protocols are letters-only, Internet domains need at least one dot, and ports are only numeric.

I’m using Chrome version 5, the latest in a long history of browsers. Surely it’s long past time to kill off the http://. And if you look closely, you’ll see the iPhone already has.

Satchmo/Django: “ProgrammingError: can’t adapt type ‘__proxy__'”

I got the above error when laoding a shipping module in Satchmo, but upon working out the cause, I reckoned it must be a pretty common error these days.

The exception is raised in /django/db/backends/util.py, line 19.
When I checked the local vars of the query.py step, line 2369, I got the following SQL:
[sourcecode language=’sql’]
‘UPDATE “shop_order” SET “site_id” = %s, “contact_id” = %s, “ship_addressee” = %s, “ship_street1” = %s, “ship_street2” = %s, “ship_city” = %s, “ship_state” = %s, “ship_postal_code” = %s, “ship_country” = %s, “bill_addressee” = %s, “bill_street1” = %s, “bill_street2” = %s, “bill_city” = %s, “bill_state” = %s, “bill_postal_code” = %s, “bill_country” = %s, “notes” = NULL, “sub_total” = %s, “total” = %s, “discount_code” = %s, “discount” = %s, “method” = %s, “shipping_description” = %s, “shipping_method” = %s, “shipping_model” = %s, “shipping_cost” = %s, “shipping_discount” = %s, “tax” = %s, “time_stamp” = %s, “status” = %s WHERE “shop_order”.”id” = %s
with the following params:
(1, 761, u’abc abc’, u’abc’, u’abcabc’, u’abc’, u'(UK32)’, u’E17 8QG’, u’GB’, u’abc abc’, u’abc’, u’abcabc’, u’abc’, u'(UK32)’, u’E17 8QG’, u’GB’, u’13.2500000000′, u’15.0000000000′, ”, u’0E-10′, u’Online’, ‘Dots Postage and Packing’, , ‘dotship’, u’1.7500000000′, u’0E-10′, u’0E-10′, u’2010-05-05 14:13:07.134682′, u”, 713)

You can see the __proxy__ that shouldn’t be there.

Looking back at my code that provides that particular value, I found I’d used the _() shortcut, which in this file, is bound to ugettext_lazy. Of course, this is the problem! The lazy evaluation isn’t being executed before the query is evaluated.

To fix, either use gettext directly, or change the shortcut for _ from gettext_lazy to gettext.

Replacing the Satchmo homepage by overriding URLs

You can override URLs used by Satchmo by using the built-in urlhelper.

So my project urls.py looks a bit like this:
[sourcecode language=”python”]
from django.conf.urls.defaults import *

from satchmo_store.urls import urlpatterns

from django.conf import settings
from satchmo_utils import urlhelper

urlpatterns += patterns(”,
#add my normal urls here
(r’^blog/index/$’, ‘myblog.views.blogindex’),
(r’^photos/’, include(‘photoapp.urls’)),

#add override urls here (match the name from satchmo’s url files)
url(r’^$’, ‘myblog.views.homepage’, {}, name=’satchmo_shop_home’),