djdb/tag_util.py
def modify_tags_and_save(user, obj, to_add, to_remove):
    """Modify the set of tags attached to an object, and save to the datastore.

    Args:
      user: The User object of the person responsible for this change
        to the tags.
      obj: The object (either an Album or a Track) containing the tags.
      to_add: A sequence of tags to add to the object.
      to_remove: A sequence of tags to remove from the object.

    Returns:
      True if a modified version of the object was saved, or False if
      no changes were necessary.
    """
    to_add = list(set(to_add).difference(obj.current_tags))
    to_remove = list(set(to_remove).intersection(obj.current_tags))
    if not (to_add or to_remove):
        return False
    obj.current_tags = list(
        set(obj.current_tags).union(to_add).difference(to_remove))
    tag_edit = models.TagEdit(parent=obj, subject=obj, author=user,
                              added=to_add, removed=to_remove)
    # The two objects are in the same entity group, so saving them
    # is an all-or-nothing operation.
    AutoRetry(db).save([obj, tag_edit])
    
    # Update search indexer.
    idx = search.Indexer(obj.parent_key())
    for tag in to_remove:
        idx.remove_key(obj.key(), 'tag', tag)
    for tag in to_add:
        idx.add_key(obj.key(), 'tag', tag)
    idx.save()
    
    return True
Modify the set of tags attached to an object, and save to the datastore.

    Args:
      user: The User object of the person responsible for this change
        to the tags.
      obj: The object (either an Album or a Track) containing the tags.
      to_add: A sequence of tags to add to the object.
      to_remove: A sequence of tags to remove from the object.

    Returns:
      True if a modified version of the object was saved, or False if
      no changes were necessary.
    
Modify the set of tags attached to an object, and save to the datastore.
Modify the set of tags attached to an object and save to the datastore .
def modify_tags_and_save(user, obj, to_add, to_remove):
    to_add = list(set(to_add).difference(obj.current_tags))
    to_remove = list(set(to_remove).intersection(obj.current_tags))
    if not (to_add or to_remove):
        return False
    obj.current_tags = list(
        set(obj.current_tags).union(to_add).difference(to_remove))
    tag_edit = models.TagEdit(parent=obj, subject=obj, author=user,
                              added=to_add, removed=to_remove)
    AutoRetry(db).save([obj, tag_edit])
    idx = search.Indexer(obj.parent_key())
    for tag in to_remove:
        idx.remove_key(obj.key(), 'tag', tag)
    for tag in to_add:
        idx.add_key(obj.key(), 'tag', tag)
    idx.save()
    return True
def modify_tags_and_save ( user , obj , to_add , to_remove ) : to_add = list ( set ( to_add ) . difference ( obj . current_tags ) ) to_remove = list ( set ( to_remove ) . intersection ( obj . current_tags ) ) if not ( to_add or to_remove ) : return False obj . current_tags = list ( set ( obj . current_tags ) . union ( to_add ) . difference ( to_remove ) ) tag_edit = models . TagEdit ( parent = obj , subject = obj , author = user , added = to_add , removed = to_remove ) AutoRetry ( db ) . save ( [ obj , tag_edit ] ) idx = search . Indexer ( obj . parent_key ( ) ) for tag in to_remove : idx . remove_key ( obj . key ( ) , 'tag' , tag ) for tag in to_add : idx . add_key ( obj . key ( ) , 'tag' , tag ) idx . save ( ) return True
Modify the set of tags attached to an object, and save to the datastore.
Modify the set of tags attached to an object and save to the datastore .
"""Modify the set of tags attached to an object, and save to the datastore.

    Args:
      user: The User object of the person responsible for this change
        to the tags.
      obj: The object (either an Album or a Track) containing the tags.
      to_add: A sequence of tags to add to the object.
      to_remove: A sequence of tags to remove from the object.

    Returns:
      True if a modified version of the object was saved, or False if
      no changes were necessary.
    """ # The two objects are in the same entity group, so saving them # is an all-or-nothing operation. # Update search indexer.
True if a modified version of the object was saved, or False if
no changes were necessary.
True if a modified version of the object was saved or False if no changes were necessary .
user
The User object of the person responsible for this change
to the tags.
The User object of the person responsible for this change to the tags .
obj
The object (either an Album or a Track) containing the tags.
The object ( either an Album or a Track ) containing the tags .
to_add
A sequence of tags to add to the object.
A sequence of tags to add to the object .
to_remove
A sequence of tags to remove from the object.
A sequence of tags to remove from the object .