improved handling of POST requests with certain content types

Requests do not always have the data attribute populated by lower WSGI layers.  They do only for certain content types.
For this case (and below) it's more idiomatic to use `getattr(request, 'data', None)` which will get `data` or fallback to `None` if the attribute does not exist. This replaces the `hasattr` call and the last assertion. Also, use single quotes for strings, unless the string contains a single quote itself.