def pymongo_class_wrapper(f, pymongo_class):
    'Executes the coroutine f and wraps its result in a Motor class.\n\n    See WrapAsync.\n    '

    @functools.wraps(f)
    async def _wrapper(self, *args, **kwargs):
        result = (await f(self, *args, **kwargs))
        if (result.__class__ == pymongo_class):
            return self.wrap(result)
        else:
            return result
    return _wrapper
Executes the coroutine f and wraps its result in a Motor class.

See WrapAsync.
def pymongo_class_wrapper(f, pymongo_class):
    'Executes the coroutine f and wraps its result in a Motor class.\n\n    See WrapAsync.\n    '

    @functools.wraps(f)
    async def _wrapper(self, *args, **kwargs):
        result = (await f(self, *args, **kwargs))
        if (result.__class__ == pymongo_class):
            return self.wrap(result)
        else:
            return result
    return _wrapper