Correct declaration for scope_key.

@nedbat @cpennington Previously, this code was: 

1) Missing the field name. 
2) Gave relatively unclean keys. 

This PR fixes both issue. 

Rapid review would be appreciated, since we're about to start prototyping things on prod which rely on this. If we can get this out, it will save us a migration later. 
Oh. Comment is out-of-date. I moved the logic around such that escape happens such that this substitution happens after escaping. So NONE.NONE will become NONE..NONE if in the source, and NONE.NONE if the field is not used. 

Will fix comment.