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?
Reason to call this `context` instead of `state`? Seems like we should keep the nomenclature the same.