code: def setup_default_permissions(session, instance):
      
      if instance not in session.new or not isinstance(instance, Entity):
          return
  
      if not current_app:
          # working outside app_context. Raw object manipulation
          return
  
      _setup_default_permissions(instance)
docs: Setup default permissions on newly created entities according to.
  
      :attr:`Entity.__default_permissions__`.