Author Archive

Jaws screen-reader vs. Javascript modifying the DOM

Adam Alton - November 6th, 2009

We’ve just finished building a site that is aimed largely at users with disabilities, and as a result we did quite a bit of testing with the Jaws screen reader to see how the site appears to a blind user.

I got into quite a fight with Jaws, Javascript and bad magic.  I was adding some Javascript to modify a Wysiwyg editor to make it a bit more screen-reader friendly.  At first it seemed that the Javascript just wasn’t working, but further playing revealed that it was but that Jaws wasn’t seeing the modifications that Javascript had made to the page, which was odd, as Jaws was able to see the Wysiwyg editor which itself had been created by Javascript  And sometimes the Javascript just made Jaws read out the text for one link when the keyboard focus was clearly on another.

It turns out that (apparently) Jaws scans the web page when it finishes loading and creates its own copy of the elements on the page, so that when the user tabs through the items on the page Jaws tabs through its own copy of the page and reads out the elements.

Tbe problem is that a lot of Javascript gets run at page load time, (either because the <script> tags have been put at the end of the body, or because there’s some kind of jQuery type $(document).ready() thing in use).  And it’s at page load time that Jaws makes its secret copy of your page.  So if your Javascript is fast enough then it will run before Jaws reads the page, but if it’s too slow then Jaws wont know about the changes to the page, and so when your user tabs through the items on the page Jaws will read out the item that it thinks is there, even if it’s not.

Using pdb in Zope page templates

Adam Alton - November 5th, 2009

It occurred to me a while ago that it must be possible to get into PDB in a Zope page template by using the ‘python:’ TALE and the magic ‘modules’ variable that is available there.  And you can!  It’s really dirty, but I’m sure it must be possible to do something useful with it:

<tal:x define=”x python:modules['pdb'].set_trace()” />

When the page is loaded it successfully drops you into the Python Debugger in the terminal, but it seems to be in some kind of context-less, etherial, undefined mystery state in which you can’t access any of the things that you would normally be able to access with python in a tal template.

Can anyone take this a step further and get it to be useful?

Zope bin/instance status tells lies. Sometimes.

Adam Alton - October 30th, 2009

If you’ve got a Zope instance running (in the background, i.e. started with bin/instance start, not bin/instance fg), then you can type bin/instance status and it will tell you whether or not it’s running.  But sometimes it lies.

It depends on which user you as logged in as.  I haven’t figured out the exact details, but basically if your user doesn’t have high enough permissions then bin/instance status will say “Daemon manager not running”, even though the instance IS running.  If you type su root and then do bin/instance status again it will tell the truth.

This can be a nightmare if you’re going through a load of old sites on a server trying to see if any of them are still running.  You think they’re not.  And then you realise that you’ve been lied to and have to go through them all again.  Maybe this blog post will save you having to go through the same hassle.

Stop Firefox Address Bar Selecting All On-Click And Other Cool Stuff

Adam Alton - October 30th, 2009

Last night I was at the 2009 Plone Conference in Budapest, and got chatting to Alexander Limi, the man in charge of UI design in Firefox 4.  He revealed a little secret….

about:config

Type that little gem into your Firefox address bar and it lets you in to a whole world of hidden settings.  The first thing I looked for was a setting to stop the address bar from selecting the whole address when you click on it.  I love the awesome bar (I know some people hate it, but I actually like it), but the annoying select all on-click nonsense that arrived as part of it has made me swear on a daily basis.  Until now.

Search for this in the about:config settings
browser.urlbar.clickSelectsAll

Awesome.

On a similar subject there’s some seriously awesome stuff coming in Firefox 4, check out Alexander Limi’s blog at http://limi.net/.

isinstance function in Zope restricted Python

Adam Alton - October 8th, 2009

Just like in normal Python, in Zope’s restricted Python you can use isinstance(var, type) to detect if a variable is of the given type or not:

>>> print isinstance(‘my string’, str)
>>> True

Which works fine.  But then you try this:

>>> print isinstance(['my','list'], list)
>>> TypeError: isinstance() arg 2 must be a class, type, or tuple of classes and types

WTF?

For some reason it doesn’t like the list type.  You can use str or int, but not list.  I’m still not sure why this is, and right now I don’t have the time to find out.  But the alternative solution is to use Zope Python’s same_type function.

>>> print same_type(['my','list'], list)
>>> True

OS X Apache Web Sharing not starting after Time Machine restore

Adam Alton - September 29th, 2009

The other day I had to restore my Mac from its Time Machine back up (I installed Snow Leopard for a sneak peak, fully knowing that it would completely break python2.4 and I’d have to restore back to Leopard in order to be able to do anything that would be deemed as ‘work’ on Monday).

It restored fine, but a week or so later I went to http://localhost/~my-username/ to find that Apache was dead.  Nothing.  Not a sausage.  Even though Web Sharing was on in System Preferences.

Console was saying this:
org.apache.httpd[4464] Unable to open logs
com.apple.launchd[1] (org.apache.httpd[4464]) Exited with exit code: 1
com.apple.launchd[1] (org.apache.httpd) Throttling respawn: Will start in 10 seconds
org.apache.httpd[4466] (2) No such file or directory: httpd: could not open error log file /private/var/log/apache2/error_log.

The solution?…

Open Terminal (/Applications/Utilities/Terminal) and type this:

cd /private/var/log
sudo mkdir apache2

Nailed.

$_SERVER['REQUEST_URI'] in Zope

Adam Alton - September 11th, 2009

Having a head that contains a PHP-shaped hammer I have a tendency to look for PHP-shaped nails when trying to make stuff.  So I’ve always been annoyed at not being able to find the equivalent of $_SERVER['REQUEST_URI'] in Zope.

Then the other day, when Rich was tweaking (read:fixing) the app that I built as my training project when I started at Rubber Towers he stuck in this:

x = self.REQUEST.ACTUAL_URL

Bingo!

It gives you the actual url that was requested by the browser, query string and all.  Sweet.