parameters: (allow_nesting=False)
docstring: Batches the role ancestor rebuild work necessary whenever role-role
      relations change. This can result in a big speedup when performing
      any bulk manipulation.
  
      WARNING: Calls to anything related to checking access/permissions
      while within the context of the batch_role_ancestor_rebuilding will
      likely not work.
docstring_summary: Batches the role ancestor rebuild work necessary whenever role-role
      relations change. This can result in a big speedup when performing
      any bulk manipulation.
docstring_tokens: Batches the role ancestor rebuild work necessary whenever role - role relations change . This can result in a big speedup when performing any bulk manipulation .
function: def batch_role_ancestor_rebuilding(allow_nesting=False):
      """
      Batches the role ancestor rebuild work necessary whenever role-role
      relations change. This can result in a big speedup when performing
      any bulk manipulation.
  
      WARNING: Calls to anything related to checking access/permissions
      while within the context of the batch_role_ancestor_rebuilding will
      likely not work.
      """
  
      batch_role_rebuilding = getattr(tls, 'batch_role_rebuilding', False)
  
      try:
          setattr(tls, 'batch_role_rebuilding', True)
          if not batch_role_rebuilding:
              setattr(tls, 'additions', set())
              setattr(tls, 'removals', set())
          yield
  
      finally:
          setattr(tls, 'batch_role_rebuilding', batch_role_rebuilding)
          if not batch_role_rebuilding:
              additions = getattr(tls, 'additions')
              removals = getattr(tls, 'removals')
              with transaction.atomic():
                  Role.rebuild_role_ancestor_list(list(additions), list(removals))
              delattr(tls, 'additions')
              delattr(tls, 'removals')
function_tokens: def batch_role_ancestor_rebuilding ( allow_nesting = False ) : batch_role_rebuilding = getattr ( tls , 'batch_role_rebuilding' , False ) try : setattr ( tls , 'batch_role_rebuilding' , True ) if not batch_role_rebuilding : setattr ( tls , 'additions' , set ( ) ) setattr ( tls , 'removals' , set ( ) ) yield finally : setattr ( tls , 'batch_role_rebuilding' , batch_role_rebuilding ) if not batch_role_rebuilding : additions = getattr ( tls , 'additions' ) removals = getattr ( tls , 'removals' ) with transaction . atomic ( ) : Role . rebuild_role_ancestor_list ( list ( additions ) , list ( removals ) ) delattr ( tls , 'additions' ) delattr ( tls , 'removals' )