Extract decorator require_context

Extract decorator for use by multiple DB backends.

Change-Id: Ifb8909cd2d493db1e8716007699a017384b4c82e