code: def scoped(self, func):
          
          @wraps(func)
          def wrapper(*args, **kwargs):
              scope = kwargs.get("scope", self.__factory__.default_scope)
              with self.scoped_to(scope):
                  return func(*args, **kwargs)
          return wrapper
docs: Decorator to switch scopes.