'Context manager to make an object call as an admin.
This temporarily modifies the context embedded in an object to
be elevated() and restores it after the call completes. Example
usage:
with obj.obj_as_admin():
obj.save()'

@contextlib.contextmanager
def obj_as_admin(self):

    if (self._context is None):
        raise exception.OrphanedObjectError(method='obj_as_admin', objtype=self.obj_name())
    original_context = self._context
    self._context = self._context.elevated()
    try:
        (yield)
    finally:
        self._context = original_context
