Like Tim said, rather let the database do your work for you:

from sqlalchemy.sql import and_

def checkAuthor(self, new_author, edit=False):
    """
    Returns True when the given Author is already in the list elsewise False.
    """
    authors = self.songmanager.get_objects_filtered(Author,
        and_(
            Author.first_name == new_author.first_name,
            Author.last_name == new_author.last_name,
            Author.display_name == new_author.display_name
        )
    )
    return edit or (len(authors) > 0)

-- 
https://code.launchpad.net/~googol-hush/openlp/trivial/+merge/29642
Your team OpenLP Core is subscribed to branch lp:openlp.

_______________________________________________
Mailing list: https://launchpad.net/~openlp-core
Post to     : [email protected]
Unsubscribe : https://launchpad.net/~openlp-core
More help   : https://help.launchpad.net/ListHelp

Reply via email to