zeeguu/core/model/starred_article.py
def find_or_create(cls, session, user: User, _url, _title: str, _language):
        """

            create a new object and add it to the db if it's not already there
            otherwise retrieve the existing object and update

            in case of creation, the created object is incomplete

\        """

        language = Language.find(_language)
        url = Url.find_or_create(session, _url, _title)

        try:
            return cls.query.filter_by(
                user=user,
                url=url
            ).one()
        except NoResultFound:
            try:
                new = cls(user, url, _title, language)
                session.add(new)
                session.commit()
                return new
            except Exception as e:
                from sentry_sdk import capture_exception
                capture_exception(e)
                print ("seems we avoided a race condition")
                session.rollback()
                return cls.query.filter_by(
                    user=user,
                    url=url
                ).one()


            create a new object and add it to the db if it's not already there
            otherwise retrieve the existing object and update

            in case of creation, the created object is incomplete

\        
create a new object and add it to the db if it's not already there
otherwise retrieve the existing object and update

in case of creation, the created object is incomplete


create a new object and add it to the db if it ' s not already there otherwise retrieve the existing object and update in case of creation the created object is incomplete
def find_or_create(cls, session, user: User, _url, _title: str, _language):
        language = Language.find(_language)
        url = Url.find_or_create(session, _url, _title)
        try:
            return cls.query.filter_by(
                user=user,
                url=url
            ).one()
        except NoResultFound:
            try:
                new = cls(user, url, _title, language)
                session.add(new)
                session.commit()
                return new
            except Exception as e:
                from sentry_sdk import capture_exception
                capture_exception(e)
                print ("seems we avoided a race condition")
                session.rollback()
                return cls.query.filter_by(
                    user=user,
                    url=url
                ).one()
def find_or_create ( cls , session , user : User , _url , _title : str , _language ) : language = Language . find ( _language ) url = Url . find_or_create ( session , _url , _title ) try : return cls . query . filter_by ( user = user , url = url ) . one ( ) except NoResultFound : try : new = cls ( user , url , _title , language ) session . add ( new ) session . commit ( ) return new except Exception as e : from sentry_sdk import capture_exception capture_exception ( e ) print ( "seems we avoided a race condition" ) session . rollback ( ) return cls . query . filter_by ( user = user , url = url ) . one ( )
create a new object and add it to the db if it's not already there
otherwise retrieve the existing object and update
create a new object and add it to the db if it ' s not already there otherwise retrieve the existing object and update
"""

            create a new object and add it to the db if it's not already there
            otherwise retrieve the existing object and update

            in case of creation, the created object is incomplete

\        """
cls
session
user
User
_url
_title
str
_language