Example #1
0
    def create(self, args):
        args['repo'] = self.get_repo_name()
        comment = Comment(self.req, self.env, args)
        comment.validate()
        comment.time = int(time())
        column_names_to_insert = [
            column_name for column_name in comment.columns
            if column_name != 'id'
        ]
        values = [
            getattr(comment, column_name)
            for column_name in column_names_to_insert
        ]
        comment_id = [None]

        @self.env.with_transaction()
        def insert_comment(db):
            cursor = db.cursor()
            sql = "INSERT INTO code_comments (%s) values(%s)" % (', '.join(
                column_names_to_insert), ', '.join(['%s'] * len(values)))
            self.env.log.debug(sql)
            cursor.execute(sql, values)
            comment_id[0] = db.get_last_id(cursor, 'code_comments')

        CodeCommentSystem(self.env).comment_created(
            Comments(self.req, self.env).by_id(comment_id[0]))

        return comment_id[0]
 def create(self, args):
     comment = Comment(self.req, self.env, args)
     comment.validate()
     comment.time = int(time())
     values = [getattr(comment, column_name) for column_name in comment.columns if column_name != 'id']
     comment_id = [None]
     @self.env.with_transaction()
     def insert_comment(db):
         cursor = db.cursor()
         sql = "INSERT INTO code_comments values(NULL, %s)" % ', '.join(['%s'] * len(values))
         cursor.execute(sql, values)
         comment_id[0] = db.get_last_id(cursor, 'code_comments')
     return comment_id[0]
    def create(self, args):
        comment = Comment(self.req, self.env, args)
        comment.validate()
        comment.time = int(time())
        column_names_to_insert = [column_name for column_name in comment.columns if column_name != 'id']
        values = [getattr(comment, column_name) for column_name in column_names_to_insert]
        comment_id = [None]
        @self.env.with_transaction()
        def insert_comment(db):
            cursor = db.cursor()
            sql = "INSERT INTO code_comments (%s) values(%s)" % (', '.join(column_names_to_insert), ', '.join(['%s'] * len(values)))
            self.env.log.debug(sql)
            cursor.execute(sql, values)
            comment_id[0] = db.get_last_id(cursor, 'code_comments')

        CodeCommentSystem(self.env).comment_created(
            Comments(self.req, self.env).by_id(comment_id[0]))

        return comment_id[0]
    def create(self, args):
        comment = Comment(self.req, self.env, args)
        comment.validate()
        comment.time = int(time())
        column_names_to_insert = [n for n in comment.columns if n != 'id']
        values = [getattr(comment, n) for n in column_names_to_insert]
        comment_id = [None]

        with self.env.db_transaction as db:
            cursor = db.cursor()
            cursor.execute("""
                INSERT INTO code_comments (%s) VALUES(%s)
                """ % (', '.join(column_names_to_insert),
                       ', '.join(['%s'] * len(values))), values)
            comment_id[0] = db.get_last_id(cursor, 'code_comments')

        CodeCommentSystem(self.env).comment_created(
            Comments(self.req, self.env).by_id(comment_id[0]))

        return comment_id[0]
Example #5
0
    def create(self, args):
        comment = Comment(self.req, self.env, args)
        comment.validate()
        comment.time = int(time())
        column_names_to_insert = [n for n in comment.columns if n != 'id']
        values = [getattr(comment, n) for n in column_names_to_insert]
        comment_id = [None]

        with self.env.db_transaction as db:
            cursor = db.cursor()
            cursor.execute(
                """
                INSERT INTO code_comments (%s) VALUES(%s)
                """ % (', '.join(column_names_to_insert), ', '.join(
                    ['%s'] * len(values))), values)
            comment_id[0] = db.get_last_id(cursor, 'code_comments')

        CodeCommentSystem(self.env).comment_created(
            Comments(self.req, self.env).by_id(comment_id[0]))

        return comment_id[0]
Example #6
0
 def comment_from_row(self, row):
     return Comment(self.req, self.env, row)