code: def hold_policy(document, policy, server=False):
      
      old_policy = document._hold
      document._hold = policy
      try:
          yield
      finally:
          if server and not old_policy:
              document.unhold()
          else:
              document._hold = old_policy
docs: Context manager to temporary override the hold policy.