Eek, I didn't consider that it was a regular old assert -- use of the assert keyword should be removed in favor of a condition:
if belongs_to and data['tenant']['id'] != belongs_to: raise exceptions.Unauthorized('Token does not belong to specified tenant.')
(asserts are removed with compile-time optimization and wouldn't raise a useful error to the API)
Eek, I didn't consider that it was a regular old assert -- use of the assert keyword should be removed in favor of a condition:
if belongs_to and data['tenant' ]['id'] != belongs_to: Unauthorized( 'Token does not belong to specified tenant.')
raise exceptions.
(asserts are removed with compile-time optimization and wouldn't raise a useful error to the API)