Let custom typecasters access global state. Fixes #395

Fixed existing tests but didn't add any.  The only real worry is the website.py change - is `state` the right parameter?  is `state['state']` the right thing to pass to all the typecasters?
I almost called it _