Changeset 2577

Show
Ignore:
Timestamp:
08/17/07 20:06:35 (1 year ago)
Author:
djeebus
Message:

PeerReviewPlugin:

Check ChangeLog?. Fixes #1942 and #1727.

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • peerreviewplugin/0.10/ChangeLog

    r2575 r2577  
     12007.08.17: djeebus: Fixed #1942 (database compatibility) 
     22007.08.17: djeebus: Fixed #1727 (cannot submit comment w/o attachment) 
     3 
  • peerreviewplugin/0.10/codereview/CodeReviewStruct.py

    r717 r2577  
    3535        if(row != None): 
    3636            #initialize variables 
    37             self.IDReview = `row[0]` 
     37            self.IDReview = row[0] 
    3838            self.Author = row[1] 
    3939            self.Status = row[2] 
     
    5050            cursor.execute(query) 
    5151            db.commit() 
    52             cursor.execute("SELECT last_insert_rowid() FROM CodeReviews") 
    53             self.IDReview = `cursor.fetchone()[0]` 
     52            self.IDReview = cursor.lastrowid; 
    5453        else: 
    5554        #Update information in existing database entry 
  • peerreviewplugin/0.10/codereview/dbEscape.py

    r717 r2577  
    1313def dbEscape(text): 
    1414    if isinstance(text, int): 
    15         return str(text) 
    16     return text.replace("'", "''") 
     15        return `text` 
     16    elif isinstance(text, long): 
     17        return `text` 
     18    else: 
     19        return text.replace("'", "''") 
  • peerreviewplugin/0.10/codereview/peerReviewCommentCallback.py

    r717 r2577  
    3737 
    3838 
    39        req.hdf['invalid'] = 0 
     39        req.hdf['invalid'] = 0 
    4040        req.hdf['trac.href.peerReviewCommentCallback'] = self.env.href.peerReviewCommentCallback() 
    4141        actionType = req.args.get('actionType') 
     
    110110        #the trac wiki code 
    111111         
    112         if req.args.has_key('FileUp'): 
    113              upload = req.args['FileUp'] 
    114              if upload.filename: 
    115                  self.path = os.path.join(self.env.path, 'attachments', 'CodeReview', urllib.quote(struct.IDFile)) 
    116                  self.path = os.path.normpath(self.path)  
    117                  size = 0 
    118                  if hasattr(upload.file, 'fileno'): 
    119                      size = os.fstat(upload.file.fileno())[6] 
    120                  else: 
    121                      size = upload.file.len 
    122                  if size != 0: 
    123                      filename = urllib.unquote(upload.filename) 
    124                      filename = filename.replace('\\', '/').replace(':', '/') 
    125                      filename = os.path.basename(filename) 
    126                      import sys, unicodedata 
    127                      if sys.version_info[0] > 2 or (sys.version_info[0] == 2 and sys.version_info[1] >= 3): 
    128                          filename = unicodedata.normalize('NFC',unicode(filename,'utf-8')).encode('utf-8') 
    129                      attachments_dir = os.path.join(os.path.normpath(self.env.path),'attachments') 
    130                      commonprefix = os.path.commonprefix([attachments_dir, self.path]) 
    131                      assert commonprefix == attachments_dir 
    132                      if not os.access(self.path, os.F_OK): 
    133                          os.makedirs(self.path) 
    134                      path, targetfile = util.create_unique_file(os.path.join(self.path,filename)) 
    135                      try: 
    136                          shutil.copyfileobj(upload.file, targetfile) 
    137                          struct.AttachmentPath = os.path.basename(path) 
    138                      finally: 
    139                          targetfile.close() 
    140                      
     112        if req.args.has_key('FileUp'): 
     113            upload = req.args['FileUp'] 
     114            if upload and upload.filename: 
     115                self.path = os.path.join(self.env.path, 'attachments', 'CodeReview', urllib.quote(struct.IDFile)) 
     116                self.path = os.path.normpath(self.path)  
     117                size = 0 
     118                if hasattr(upload.file, 'fileno'): 
     119                    size = os.fstat(upload.file.fileno())[6] 
     120                else: 
     121                    size = upload.file.len 
     122                if size != 0: 
     123                    filename = urllib.unquote(upload.filename) 
     124                    filename = filename.replace('\\', '/').replace(':', '/') 
     125                    filename = os.path.basename(filename) 
     126                    import sys, unicodedata 
     127                    if sys.version_info[0] > 2 or (sys.version_info[0] == 2 and sys.version_info[1] >= 3): 
     128                        filename = unicodedata.normalize('NFC',unicode(filename,'utf-8')).encode('utf-8') 
     129                    attachments_dir = os.path.join(os.path.normpath(self.env.path),'attachments') 
     130                    commonprefix = os.path.commonprefix([attachments_dir, self.path]) 
     131                    assert commonprefix == attachments_dir 
     132                    if not os.access(self.path, os.F_OK): 
     133                        os.makedirs(self.path) 
     134                    path, targetfile = util.create_unique_file(os.path.join(self.path,filename)) 
     135                    try: 
     136                        shutil.copyfileobj(upload.file, targetfile) 
     137                        struct.AttachmentPath = os.path.basename(path) 
     138                    finally: 
     139                        targetfile.close() 
    141140        struct.save(self.env.get_db_cnx()) 
    142141 
     
    181180        width = (5+nodesIn*factor); 
    182181         
    183         html = "<table width=\"400px\" style=\"border-collapse: collapse\" id=\"" + comment.IDParent + ":" + comment.IDComment + "\">" 
     182        html = "<table width=\"400px\" style=\"border-collapse: collapse\" id=\"" + `comment.IDParent` + ":" + `comment.IDComment` + "\">" 
    184183        if not first: 
    185184            html += "<tr><td width=\"" + `width` + "px\"></td>" 
     
    188187        html += "<td colspan=\"2\" align=\"left\" width=\"" + `(400-100-width)` + "px\">Author: " + comment.Author + "</td>" 
    189188        html += "<td width=\"100px\" align=\"right\">" + util.format_date(comment.DateCreate) + "</td></tr>" 
    190         html += "<tr><td width=\"" + `width` + "px\"></td><td valign=\"top\" width=\"" + `factor` + "px\" id=\"" + comment.IDComment + "TreeButton\">" 
     189        html += "<tr><td width=\"" + `width` + "px\"></td><td valign=\"top\" width=\"" + `factor` + "px\" id=\"" + `comment.IDComment` + "TreeButton\">" 
    191190        if not childrenHTML == "": 
    192191            html += "<img src=\"" + self.env.href.chrome() + "/hw/images/minus.gif\" onclick=\"collapseComments(" + comment.IDComment + ");\">" 
     
    199198        html += "</td>" 
    200199        html += "<td width=\"100px\" align=\"right\">" 
    201         html += "<a href=\"javascript:addComment(" + LineNum + ", " + IDFile + ", " +  comment.IDComment + ")\">Reply</a></td></tr>" 
     200        html += "<a href=\"javascript:addComment(" + `LineNum` + ", " + `IDFile` + ", " +  `comment.IDComment` + ")\">Reply</a></td></tr>" 
    202201        html += "<tr height=\"3\"><td width=\"" + `width` + "px\"></td><td width=\"" + `factor` + "px\"></td><td width=\"" + `(400-width-factor)` + "px\" colspan=\"2\"></td></tr>" 
    203202        html += "</table>" 
  • peerreviewplugin/0.10/codereview/peerReviewNew.py

    r717 r2577  
    135135                    review.Status = "Closed" 
    136136                    review.save(db) 
    137                 returnid = self.createCodeReview(req); 
     137                returnid = self.createCodeReview(req) 
    138138                #If no errors then redirect to the viewCodeReview page 
    139                 req.redirect(self.env.href.peerReviewView() + '?Review=' + returnid
     139                req.redirect(self.env.href.peerReviewView() + '?Review=' + str(returnid)
    140140            else: 
    141141                req.hdf['new'] = "yes" 
  • peerreviewplugin/0.10/codereview/peerReviewPerform.py

    r2270 r2577  
    132132        req.hdf['review.reviewID'] = resultFile.IDReview 
    133133        #make these global for the line annotator 
    134         self.lineEnd = string.atoi(resultFile.LineEnd) 
    135         self.lineStart = string.atoi(resultFile.LineStart) 
     134        self.lineEnd = resultFile.LineEnd 
     135        self.lineStart = resultFile.LineStart 
    136136 
    137137        #if the repository can't be found - display an error message 
  • peerreviewplugin/0.10/codereview/ReviewCommentStruct.py

    r717 r2577  
    4545        if(row != None): 
    4646            #initialize variables 
    47             self.IDComment = `row[0]` 
    48             self.IDFile = `row[1]` 
    49             self.IDParent = `row[2]` 
    50             self.LineNum = `row[3]` 
     47            self.IDComment = row[0] 
     48            self.IDFile = row[1] 
     49            self.IDParent = row[2] 
     50            self.LineNum = row[3] 
    5151            self.Author = row[4] 
    5252            self.Text = row[5] 
     
    6262            cursor.execute(query) 
    6363            db.commit() 
    64             cursor.execute("SELECT last_insert_rowid() FROM ReviewComments") 
    65             self.IDComment = `cursor.fetchone()[0]` 
     64            self.IDComment = cursor.lastrowid; 
    6665        else: 
    6766        #Update information in existing database entry 
  • peerreviewplugin/0.10/codereview/ReviewerStruct.py

    r717 r2577  
    2929        if(row != None): 
    3030            #initialize variables 
    31             self.IDReview = `row[0]` 
     31            self.IDReview = row[0] 
    3232            self.Reviewer = row[1] 
    3333            self.Status = row[2] 
    34             self.Vote = `row[3]` 
     34            self.Vote = row[3] 
    3535 
    3636    def save(self, db): 
  • peerreviewplugin/0.10/codereview/ReviewFilesStruct.py

    r717 r2577  
    3535        if(row != None): 
    3636            #initialize variables 
    37             self.IDFile = `row[0]` 
    38             self.IDReview = `row[1]` 
     37            self.IDFile = row[0] 
     38            self.IDReview = row[1] 
    3939            self.Path = row[2] 
    40             self.LineStart = `row[3]` 
    41             self.LineEnd = `row[4]` 
    42             self.Version = `row[5]` 
     40            self.LineStart = row[3] 
     41            self.LineEnd = row[4] 
     42            self.Version = row[5] 
    4343 
    4444    def save(self, db): 
     
    4949            cursor.execute(query) 
    5050            db.commit() 
    51             cursor.execute("SELECT last_insert_rowid() FROM ReviewFiles") 
    52             self.IDFile = `cursor.fetchone()[0]` 
     51            self.IDFile = cursor.lastrowid; 
    5352        else: 
    5453        #Update information in existing database entry