Mercurial > p > roundup > code
comparison roundup/roundupdb.py @ 453:5b422e3bd05d
Performance tuning.
. Modified cgi interface to change properties only once all changes are
collected, files created and messages generated.
. Moved generation of change note to nosyreactors.
. We now check for changes to "assignedto" to ensure it's added to the
nosy list.
| author | Roche Compaan <rochecompaan@users.sourceforge.net> |
|---|---|
| date | Sat, 15 Dec 2001 19:24:39 +0000 |
| parents | 208697858c8b |
| children | fcda73536034 |
comparison
equal
deleted
inserted
replaced
| 452:7181efddce66 | 453:5b422e3bd05d |
|---|---|
| 13 # BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS | 13 # BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS |
| 14 # FOR A PARTICULAR PURPOSE. THE CODE PROVIDED HEREUNDER IS ON AN "AS IS" | 14 # FOR A PARTICULAR PURPOSE. THE CODE PROVIDED HEREUNDER IS ON AN "AS IS" |
| 15 # BASIS, AND THERE IS NO OBLIGATION WHATSOEVER TO PROVIDE MAINTENANCE, | 15 # BASIS, AND THERE IS NO OBLIGATION WHATSOEVER TO PROVIDE MAINTENANCE, |
| 16 # SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS. | 16 # SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS. |
| 17 # | 17 # |
| 18 # $Id: roundupdb.py,v 1.30 2001-12-12 21:47:45 richard Exp $ | 18 # $Id: roundupdb.py,v 1.31 2001-12-15 19:24:39 rochecompaan Exp $ |
| 19 | 19 |
| 20 __doc__ = """ | 20 __doc__ = """ |
| 21 Extending hyperdb with types specific to issue-tracking. | 21 Extending hyperdb with types specific to issue-tracking. |
| 22 """ | 22 """ |
| 23 | 23 |
| 266 | 266 |
| 267 The given text is saved as the body of the message and the node is | 267 The given text is saved as the body of the message and the node is |
| 268 appended to the "messages" field of the specified issue. | 268 appended to the "messages" field of the specified issue. |
| 269 """ | 269 """ |
| 270 | 270 |
| 271 def sendmessage(self, nodeid, msgid): | 271 def sendmessage(self, nodeid, msgid, change_note): |
| 272 """Send a message to the members of an issue's nosy list. | 272 """Send a message to the members of an issue's nosy list. |
| 273 | 273 |
| 274 The message is sent only to users on the nosy list who are not | 274 The message is sent only to users on the nosy list who are not |
| 275 already on the "recipients" list for the message. | 275 already on the "recipients" list for the message. |
| 276 | 276 |
| 341 m.append("%s%s added the comment:"%(authname, authaddr)) | 341 m.append("%s%s added the comment:"%(authname, authaddr)) |
| 342 m.append('') | 342 m.append('') |
| 343 | 343 |
| 344 # add the content | 344 # add the content |
| 345 m.append(self.db.msg.get(msgid, 'content')) | 345 m.append(self.db.msg.get(msgid, 'content')) |
| 346 | |
| 347 # add the change note | |
| 348 if change_note: | |
| 349 m.append(change_note) | |
| 346 | 350 |
| 347 # put in roundup's signature | 351 # put in roundup's signature |
| 348 if self.EMAIL_SIGNATURE_POSITION == 'bottom': | 352 if self.EMAIL_SIGNATURE_POSITION == 'bottom': |
| 349 m.append(self.email_signature(nodeid, msgid)) | 353 m.append(self.email_signature(nodeid, msgid)) |
| 350 | 354 |
| 414 web = self.ISSUE_TRACKER_WEB + 'issue'+ nodeid | 418 web = self.ISSUE_TRACKER_WEB + 'issue'+ nodeid |
| 415 email = '"%s" <%s>'%(self.INSTANCE_NAME, self.ISSUE_TRACKER_EMAIL) | 419 email = '"%s" <%s>'%(self.INSTANCE_NAME, self.ISSUE_TRACKER_EMAIL) |
| 416 line = '_' * max(len(web), len(email)) | 420 line = '_' * max(len(web), len(email)) |
| 417 return '%s\n%s\n%s\n%s'%(line, email, web, line) | 421 return '%s\n%s\n%s\n%s'%(line, email, web, line) |
| 418 | 422 |
| 419 def generateChangeNote(self, nodeid, newvalues): | 423 def generateChangeNote(self, nodeid, oldvalues): |
| 420 """Generate a change note that lists property changes | 424 """Generate a change note that lists property changes |
| 421 """ | 425 """ |
| 422 cn = self.classname | 426 cn = self.classname |
| 423 cl = self.db.classes[cn] | 427 cl = self.db.classes[cn] |
| 424 changed = {} | 428 changed = {} |
| 425 props = cl.getprops(protected=0) | 429 props = cl.getprops(protected=0) |
| 426 | 430 |
| 427 # determine what changed | 431 # determine what changed |
| 428 for key in newvalues.keys(): | 432 for key in oldvalues.keys(): |
| 429 if key in ['files','messages']: continue | 433 if key in ['files','messages']: continue |
| 430 new_value = newvalues[key] | 434 new_value = cl.get(nodeid, key) |
| 431 # the old value might be non existent | 435 # the old value might be non existent |
| 432 try: | 436 try: |
| 433 old_value = cl.get(nodeid, key) | 437 old_value = oldvalues[key] |
| 434 if type(old_value) is type([]): | 438 if type(new_value) is type([]): |
| 439 new_value.sort() | |
| 435 old_value.sort() | 440 old_value.sort() |
| 436 new_value.sort() | 441 if new_value != old_value: |
| 437 if old_value != new_value: | 442 changed[key] = old_value |
| 438 changed[key] = new_value | |
| 439 except: | 443 except: |
| 440 changed[key] = new_value | 444 changed[key] = new_value |
| 441 | 445 |
| 442 # list the changes | 446 # list the changes |
| 443 m = [] | 447 m = [] |
| 444 for propname, value in changed.items(): | 448 for propname, oldvalue in changed.items(): |
| 445 prop = cl.properties[propname] | 449 prop = cl.properties[propname] |
| 446 oldvalue = cl.get(nodeid, propname, None) | 450 value = cl.get(nodeid, propname, None) |
| 447 change = '%s -> %s'%(oldvalue, value) | |
| 448 if isinstance(prop, hyperdb.Link): | 451 if isinstance(prop, hyperdb.Link): |
| 449 link = self.db.classes[prop.classname] | 452 link = self.db.classes[prop.classname] |
| 450 key = link.labelprop(default_to_id=1) | 453 key = link.labelprop(default_to_id=1) |
| 451 if key: | 454 if key: |
| 452 if value: | 455 if value: |
| 482 l.append(link.get(entry, key)) | 485 l.append(link.get(entry, key)) |
| 483 else: | 486 else: |
| 484 l.append(entry) | 487 l.append(entry) |
| 485 if l: | 488 if l: |
| 486 change += ' -%s'%(', '.join(l)) | 489 change += ' -%s'%(', '.join(l)) |
| 490 else: | |
| 491 change = '%s -> %s'%(oldvalue, value) | |
| 487 m.append('%s: %s'%(propname, change)) | 492 m.append('%s: %s'%(propname, change)) |
| 488 if m: | 493 if m: |
| 489 m.insert(0, '----------') | 494 m.insert(0, '----------') |
| 490 m.insert(0, '') | 495 m.insert(0, '') |
| 491 return '\n'.join(m) | 496 return '\n'.join(m) |
| 492 | 497 |
| 493 # | 498 # |
| 494 # $Log: not supported by cvs2svn $ | 499 # $Log: not supported by cvs2svn $ |
| 500 # Revision 1.30 2001/12/12 21:47:45 richard | |
| 501 # . Message author's name appears in From: instead of roundup instance name | |
| 502 # (which still appears in the Reply-To:) | |
| 503 # . envelope-from is now set to the roundup-admin and not roundup itself so | |
| 504 # delivery reports aren't sent to roundup (thanks Patrick Ohly) | |
| 505 # | |
| 495 # Revision 1.29 2001/12/11 04:50:49 richard | 506 # Revision 1.29 2001/12/11 04:50:49 richard |
| 496 # fixed the order of the blank line and '-------' line | 507 # fixed the order of the blank line and '-------' line |
| 497 # | 508 # |
| 498 # Revision 1.28 2001/12/10 22:20:01 richard | 509 # Revision 1.28 2001/12/10 22:20:01 richard |
| 499 # Enabled transaction support in the bsddb backend. It uses the anydbm code | 510 # Enabled transaction support in the bsddb backend. It uses the anydbm code |
