def get_or_create(cls, name):
        """
        Return the instance of the class with the specified name. If it doesn't
        already exist, create it.
        """
        obj = cls.query.filter_by(name=name).one_or_none()
        if obj:
            return obj
        try:
            with session.begin_nested():
                obj = cls(name=name)
                session.add(obj)
                session.flush()
            return obj
        except IntegrityError:
            log.debug('Collision when adding %s(name="%s"), returning existing object',
                      cls.__name__, name)
            return cls.query.filter_by(name=name).one()
def get_or_create ( cls , name ) : obj = cls . query . filter_by ( name = name ) . one_or_none ( ) if obj : return obj try : with session . begin_nested ( ) : obj = cls ( name = name ) session . add ( obj ) session . flush ( ) return obj except IntegrityError : log . debug ( 'Collision when adding %s(name="%s"), returning existing object' , cls . __name__ , name ) return cls . query . filter_by ( name = name ) . one ( )
Return the instance of the class with the specified name. If it doesn't
        already exist, create it.