def add(cls, title, description): group = cls(title=title, description=description) try: mysql_session.add(group) mysql_session.commit() except Exception as e: mysql_session.flush() print "error in mysql commit:", e return group.id
def add(cls, title, board_id): _list = cls(board_id = board_id, title = title) try: mysql_session.add(_list) mysql_session.commit() except Exception as e: mysql_session.rollback() raise print "error in mysql commit:", e finally: mysql_session.close() return _list.id
def add(cls, board_id, user_id, content): activity = cls(board_id = board_id, user_id = user_id, content = content) try: mysql_session.add(activity) mysql_session.commit() except Exception as e: mysql_session.rollback() print "error in mysql commit:", e raise finally: mysql_session.close() return activity.id
def add(cls, title, visibility, ): #no group_id for now board = cls(title = title, visibility = visibility) #no group_id = group_id try: mysql_session.add(board) mysql_session.commit() except Exception as e: mysql_session.rollback() print "error in mysql commit:", e raise finally: mysql_session.close() return board.id
def add(cls, card_id, user_id, content): comment = cls(card_id = card_id, user_id = user_id, content = content) from models.card import Card Card.incr_comment(card_id) try: mysql_session.add(comment) mysql_session.commit() except Exception as e: mysql_session.rollback() print "error in mysql commit:", e raise finally: mysql_session.close() return comment.id
def add(cls, username, unsafe_password, user_email): safe_password = generate_password_hash(unsafe_password) user = User(username=username, password=safe_password, email=user_email) try: mysql_session.add(user) mysql_session.commit() except Exception as e: mysql_session.rollback() print e raise finally: mysql_session.close() return user.id