Changeset 1121

Show
Ignore:
Timestamp:
06/04/08 07:35:07
Author:
crchemist
Message:

Clean up code

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • qPloneComments/branches/plone-3.0/patch.py

    r1120 r1121  
    88from StringIO import StringIO 
    99from utils import * 
    10  
    11 def _mungeHeaders( messageText, mto=None, mfrom=None, subject=None): 
    12     """Sets missing message headers, and deletes Bcc. 
    13        returns fixed message, fixed mto and fixed mfrom""" 
    14     mfile=StringIO(messageText.lstrip()) 
    15     mo=rfc822.Message(mfile) 
    16  
    17     # Parameters given will *always* override headers in the messageText. 
    18     # This is so that you can't override or add to subscribers by adding them to 
    19     # the message text. 
    20     if subject: 
    21         mo['Subject'] = subject 
    22     elif not mo.getheader('Subject'): 
    23         mo['Subject'] = '[No Subject]' 
    24  
    25     if mto: 
    26         if isinstance(mto, basestring): 
    27             mto = [rfc822.dump_address_pair(addr) for addr in rfc822.AddressList(mto) ] 
    28         if not mo.getheader('To'): 
    29             mo['To'] = ','.join(mto) 
    30     else: 
    31         mto = [] 
    32         for header in ('To', 'Cc', 'Bcc'): 
    33             v = mo.getheader(header) 
    34             if v: 
    35                 mto += [rfc822.dump_address_pair(addr) for addr in rfc822.AddressList(v)] 
    36         if not mto: 
    37             raise MailHostError, "No message recipients designated" 
    38  
    39     if mfrom: 
    40         mo['From'] = mfrom 
    41     else: 
    42         if mo.getheader('From') is None: 
    43             raise MailHostError,"Message missing SMTP Header 'From'" 
    44         mfrom = mo['From'] 
    45  
    46     if mo.getheader('Bcc'): 
    47         mo.__delitem__('Bcc') 
    48  
    49     if not mo.getheader('Date'): 
    50         mo['Date'] = DateTime().rfc822() 
    51  
    52     mo.rewindbody() 
    53     finalmessage = mo 
    54     finalmessage = mo.__str__() + '\n' + mfile.read() 
    55     mfile.close() 
    56     return finalmessage, mto, mfrom 
    5710 
    5811# Patching createReply method of  
     
    13992DiscussionItemContainer.createReply = createReply 
    14093DiscussionItemContainer.getReplies = getReplies 
    141  
    142 """ 
    143 try: 
    144     from Products.MailHost import MailHost 
    145     MailHost._mungeHeaders = _mungeHeaders 
    146 except ImportError: 
    147     pass 
    148 """ 
  • qPloneComments/branches/plone-3.0/version.txt

    r1120 r1121  
    1 3.0.1 
     13.0.2