original_docstring: Merge two users in the ACL.
  
          :param target: The target user of the merge.
          :param source: The user that is being merged into `target`.
          :param relationship_attr: The name of the relationship pointing
                                    to the object associated with the ACL
                                    entry.
          
docstring: Merge two users in the ACL.
docstring_tokens: Merge two users in the ACL .
code: def merge_users(cls, target, source, relationship_attr):
          """Merge two users in the ACL.
  
          :param target: The target user of the merge.
          :param source: The user that is being merged into `target`.
          :param relationship_attr: The name of the relationship pointing
                                    to the object associated with the ACL
                                    entry.
          """
          relationship = getattr(cls, relationship_attr)
          source_principals = set(getattr(source, cls.principal_backref_name).options(joinedload(relationship)))
          target_objects = {getattr(x, relationship_attr): x
                            for x in getattr(target, cls.principal_backref_name).options(joinedload(relationship))}
          for principal in source_principals:
              existing = target_objects.get(getattr(principal, relationship_attr))
              if existing is None:
                  principal.user_id = target.id
              else:
                  existing.merge_privs(principal)
                  db.session.delete(principal)
          db.session.flush()
code_tokens: def merge_users ( cls , target , source , relationship_attr ) : relationship = getattr ( cls , relationship_attr ) source_principals = set ( getattr ( source , cls . principal_backref_name ) . options ( joinedload ( relationship ) ) ) target_objects = { getattr ( x , relationship_attr ) : x for x in getattr ( target , cls . principal_backref_name ) . options ( joinedload ( relationship ) ) } for principal in source_principals : existing = target_objects . get ( getattr ( principal , relationship_attr ) ) if existing is None : principal . user_id = target . id else : existing . merge_privs ( principal ) db . session . delete ( principal ) db . session . flush ( )
short_docstring: Merge two users in the ACL.
short_docstring_tokens: Merge two users in the ACL .
comment: """Merge two users in the ACL.
  
          :param target: The target user of the merge.
          :param source: The user that is being merged into `target`.
          :param relationship_attr: The name of the relationship pointing
                                    to the object associated with the ACL
                                    entry.
          """