Exemplo n.º 1
0
    def add_news_detail(title=None,
                        category=None,
                        img=None,
                        time=None,
                        url=None,
                        content=None,
                        artical_id=None,
                        html=None,
                        excerpt=None):

        news = News_Model(title=title,
                          category=category,
                          img=img,
                          time=time,
                          url=url,
                          artical_id=artical_id,
                          content=content,
                          html=html,
                          excerpt=excerpt)
        result = news.query.filter_by(artical_id=artical_id).all()
        if (result == None or len(result) == 0):
            from app.main import log
            log.info("add News_Model %s" % title)
            try:
                alchemy_db.session.add(news)
                alchemy_db.session.commit()
                pass
            except BaseException as e:
                log.error("add News_Model error %s" % e)
                alchemy_db.session.rollback()
                # alchemy_db.session.close()
                pass
            finally:
                pass
Exemplo n.º 2
0
    def add_movie_comment(content, movie_id):
        comment = Movie_Comment(content, movie_id)

        from app.main import log
        log.info("add_comment comment %s" % content)

        try:
            alchemy_db.session.add(comment)
            alchemy_db.session.commit()
            pass
        except BaseException as e:
            log.error(" add_movie_comment error %s" % e)
            alchemy_db.session.rollback()
            # alchemy_db.session.close()
            pass
Exemplo n.º 3
0
    def add_news_cate(type, category_id, category_name, artical_id):
        cat = News_Category(type, category_id, category_name, artical_id)
        if len(cat.query.filter_by(artical_id=artical_id).all()) == 0:
            from app.main import log
            log.info("add News_Category %s artical_id %s" %
                     (category_name, artical_id))

            try:
                alchemy_db.session.add(cat)
                alchemy_db.session.commit()
                pass
            except BaseException as e:
                log.error("add News_Category error %s" % e)
                alchemy_db.session.rollback()
                # alchemy_db.session.close()
                pass
Exemplo n.º 4
0
    def add_news_img(artical_id, url, desc):
        img = News_Img(artical_id, url, desc)
        if len(img.query.filter_by(url=url).all()) == 0 or img.query.filter_by(
                url=url).all() == None:
            from app.main import log
            log.info("add add_news_img des %s" % desc)

            try:
                alchemy_db.session.add(img)
                alchemy_db.session.commit()
                pass
            except BaseException as e:
                log.error("add News_Img error %s" % e)
                alchemy_db.session.rollback()
                # alchemy_db.session.close()
                pass
Exemplo n.º 5
0
def error(msg):

    log.error(msg)