diff --git a/roundup/mailgw.py b/roundup/mailgw.py
index fb7b6a2e3ee796065580c80a38e2e8cf8ea7f080..38b3e370e217d66706a6416973b65269649fbc2c 100644 (file)
--- a/roundup/mailgw.py
+++ b/roundup/mailgw.py
from roundup import configuration, hyperdb, date, password, rfc2822, exceptions
from roundup.mailer import Mailer, MessageSendError
from roundup.i18n import _
+from roundup.hyperdb import iter_roles
try:
import pyme, pyme.core, pyme.gpgme
yield sig
sig = sig.next
-
-def iter_roles(roles):
- ''' handle the text processing of turning the roles list
- into something python can use more easily
- '''
- for role in [x.lower().strip() for x in roles.split(',')]:
- yield role
-
-def user_has_role(db, userid, role_list):
- ''' see if the given user has any roles that appear
- in the role_list
- '''
- for role in iter_roles(db.user.get(userid, 'roles')):
- if role in iter_roles(role_list):
- return True
- return False
-
-
def check_pgp_sigs(sig, gpgctx, author):
''' Theoretically a PGP message can have several signatures. GPGME
returns status on all signatures in a linked list. Walk that
def getheader(self, name, default=None):
hdr = mimetools.Message.getheader(self, name, default)
+ # TODO are there any other False values possible?
+ # TODO if not hdr: return hdr
+ if hdr is None:
+ return None
if not hdr:
return ''
if hdr:
fcntl.flock(f.fileno(), FCNTL.LOCK_UN)
return 0
- def do_imap(self, server, user='', password='', mailbox='', ssl=0):
+ def do_imap(self, server, user='', password='', mailbox='', ssl=0,
+ cram=0):
''' Do an IMAP connection
'''
import getpass, imaplib, socket
return 1
try:
- server.login(user, password)
+ if cram:
+ server.login_cram_md5(user, password)
+ else:
+ server.login(user, password)
except imaplib.IMAP4.error, e:
self.logger.exception('IMAP login failure')
return 1
# if we've not found a valid classname prefix then force the
# scanning to handle there being a leading delimiter
- title_re = r'(?P<title>%s[^%s]+)'%(
+ title_re = r'(?P<title>%s[^%s]*)'%(
not matches['classname'] and '.' or '', delim_open)
m = re.match(title_re, tmpsubject.strip(), re.IGNORECASE)
if m:
if (title and properties.has_key('title') and not
issue_props.has_key('title')):
issue_props['title'] = title
+ if (nodeid and properties.has_key('title') and not
+ config['MAILGW_SUBJECT_UPDATES_TITLE']):
+ issue_props['title'] = cl.get(nodeid,'title')
#
# handle message-id and in-reply-to
# or we will skip PGP processing
def pgp_role():
if self.instance.config.PGP_ROLES:
- return user_has_role(self.db, author,
- self.instance.config.PGP_ROLES)
+ return self.db.user.has_role(author,
+ iter_roles(self.instance.config.PGP_ROLES))
else:
return True