Show
Ignore:
Timestamp:
05/02/09 16:44:28 (3 years ago)
Author:
John Hampton <pacopablo@…>
Children:
4e17a72f98bff34332fbca7853ac4aa7b854d997
Parents:
4bceacf6b979775083c8623c2906a66e95eefe48
git-committer:
John Hampton <pacopablo@pacopablo.com> / 2009-05-02T16:44:28Z-0700
Message:

Fleshed out framework. Begun implementation of IMAP email data source

File:
1 edited

Legend:

Unmodified
Added
Removed
  • resourcetotrac/resourcetotrac/email/util.py

    ref235ae rc8845e4  
    2020__all__ = [ 
    2121    'strip_re',  
    22     'get_resource_type', 
    23     'get_author', 
     22    'get_author_email', 
    2423    'get_cc', 
    2524] 
     
    3332    return subject 
    3433 
    35 def get_resource_type(msg): 
    36     """ Returns the resource type of the message. 
     34def get_author(env, msg): 
     35    """ Return the username of the author based on the From: address  
    3736 
    38     For emails, the resource type is contained in the subject. 
    39     ticket: 
    40         [project name] #42: Summary 
     37    env is a Trac environment. 
     38    msg is an email object 
     39    """ 
     40    address = get_author_email(msg) 
     41    cnx = env.get_db_cnx() 
     42    cur = cnx.cursor() 
     43    cur.execute("SELECT sid FROM session_attribute WHERE name = 'email' AND value = %s", (address,)) 
     44    cnx.close() 
     45    cnx = None 
    4146 
    42     wiki: 
    43         wiki:Path/Of/WikiPage 
     47def get_author_email(msg): 
     48    """ Returns the email of the author """ 
     49    return parseadr(msg['From'])[1] 
    4450 
    45     milestone: 
    46         milestone:Milestone Name  
     51def get_cc(msg): 
     52    """ Returns a list of email addresses pulled from the CC list """ 
     53    return [e[1] for e in getaddresses(msg.get_all('cc', []))] 
    4754 
    48     """  
Note: See TracChangeset for help on using the changeset viewer.