|
15 | 15 | # BASIS, AND THERE IS NO OBLIGATION WHATSOEVER TO PROVIDE MAINTENANCE, |
16 | 16 | # SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS. |
17 | 17 | # |
18 | | -# $Id: roundupdb.py,v 1.56 2002-06-14 03:54:21 dman13 Exp $ |
| 18 | +# $Id: roundupdb.py,v 1.57 2002-06-15 15:49:29 dman13 Exp $ |
19 | 19 |
|
20 | 20 | __doc__ = """ |
21 | 21 | Extending hyperdb with types specific to issue-tracking. |
|
24 | 24 | import re, os, smtplib, socket, copy, time, random |
25 | 25 | import MimeWriter, cStringIO |
26 | 26 | import base64, quopri, mimetypes |
27 | | -import rfc822 |
| 27 | +# if available, use the 'email' module, otherwise fallback to 'rfc822' |
| 28 | +try : |
| 29 | + from email.Utils import dump_address_pair as straddr |
| 30 | +except ImportError : |
| 31 | + from rfc822 import dump_address_pair as straddr |
28 | 32 |
|
29 | 33 | import hyperdb, date |
30 | 34 |
|
@@ -395,7 +399,7 @@ def send_message(self, nodeid, msgid, note, sendto): |
395 | 399 | authname = users.get(authid, 'username') |
396 | 400 | authaddr = users.get(authid, 'address') |
397 | 401 | if authaddr: |
398 | | - authaddr = rfc822.dump_address_pair( ('',authaddr) ) |
| 402 | + authaddr = straddr( ('',authaddr) ) |
399 | 403 | else: |
400 | 404 | authaddr = '' |
401 | 405 |
|
@@ -441,9 +445,9 @@ def send_message(self, nodeid, msgid, note, sendto): |
441 | 445 | writer = MimeWriter.MimeWriter(message) |
442 | 446 | writer.addheader('Subject', '[%s%s] %s'%(cn, nodeid, title)) |
443 | 447 | writer.addheader('To', ', '.join(sendto)) |
444 | | - writer.addheader('From', rfc822.dump_address_pair( |
| 448 | + writer.addheader('From', straddr( |
445 | 449 | (authname, self.db.config.ISSUE_TRACKER_EMAIL) ) ) |
446 | | - writer.addheader('Reply-To', rfc822.dump_address_pair( |
| 450 | + writer.addheader('Reply-To', straddr( |
447 | 451 | (self.db.config.INSTANCE_NAME, |
448 | 452 | self.db.config.ISSUE_TRACKER_EMAIL) ) ) |
449 | 453 | writer.addheader('MIME-Version', '1.0') |
@@ -517,16 +521,17 @@ def email_signature(self, nodeid, msgid): |
517 | 521 | # simplistic check to see if the url is valid, |
518 | 522 | # then append a trailing slash if it is missing |
519 | 523 | base = self.db.config.ISSUE_TRACKER_WEB |
520 | | - if not isinstance( base , "" ) or not base.startswith( "http://" ) : |
| 524 | + # Oops, can't do this in python2.1 |
| 525 | + #if not isinstance( base , "" ) or not base.startswith( "http://" ) : |
| 526 | + if type(base) != type("") or not base.startswith( "http://" ) : |
521 | 527 | base = "Configuration Error: ISSUE_TRACKER_WEB isn't a fully-qualified URL" |
522 | 528 | elif base[-1] != '/' : |
523 | 529 | base += '/' |
524 | 530 | web = base + 'issue'+ nodeid |
525 | | - #web = self.db.config.ISSUE_TRACKER_WEB + 'issue'+ nodeid |
526 | 531 |
|
527 | 532 | # ensure the email address is properly quoted |
528 | | - email = rfc822.dump_address_pair( self.db.config.INSTANCE_NAME , |
529 | | - self.db.config.ISSUE_TRACKER_EMAIL ) |
| 533 | + email = straddr( (self.db.config.INSTANCE_NAME , |
| 534 | + self.db.config.ISSUE_TRACKER_EMAIL) ) |
530 | 535 |
|
531 | 536 | line = '_' * max(len(web), len(email)) |
532 | 537 | return '%s\n%s\n%s\n%s'%(line, email, web, line) |
@@ -578,6 +583,18 @@ def generateChangeNote(self, nodeid, oldvalues): |
578 | 583 | changed = {} |
579 | 584 | props = cl.getprops(protected=0) |
580 | 585 |
|
| 586 | + # XXX DSH |
| 587 | + # Temporary work-around to prevent crashes and allow the issue to be |
| 588 | + # submitted. |
| 589 | + try : |
| 590 | + oldvalues.keys |
| 591 | + except AttributeError : |
| 592 | + # The arg isn't a dict. Precondition/interface violation. |
| 593 | + return '\n'.join( |
| 594 | + ('', '-'*10, |
| 595 | + "Precondition/interface Error -- 'oldvalues' isn't a dict." , |
| 596 | + '-'*10 , '' , str(oldvalues) ) ) |
| 597 | + |
581 | 598 | # determine what changed |
582 | 599 | for key in oldvalues.keys(): |
583 | 600 | if key in ['files','messages']: continue |
@@ -649,6 +666,12 @@ def generateChangeNote(self, nodeid, oldvalues): |
649 | 666 |
|
650 | 667 | # |
651 | 668 | # $Log: not supported by cvs2svn $ |
| 669 | +# Revision 1.56 2002/06/14 03:54:21 dman13 |
| 670 | +# #565992 ] if ISSUE_TRACKER_WEB doesn't have the trailing '/', add it |
| 671 | +# |
| 672 | +# use the rfc822 module to ensure that every (oddball) email address and |
| 673 | +# real-name is properly quoted |
| 674 | +# |
652 | 675 | # Revision 1.55 2002/06/11 04:58:07 richard |
653 | 676 | # detabbing |
654 | 677 | # |
|
0 commit comments