Some code style cleanup

darcs-hash:20070530062134-86b55-2670bdf7b6eebb7ad8014db9629a6e3ee36ac00c.gz
This commit is contained in:
David Rousselie
2007-05-30 08:21:34 +02:00
parent 16de054616
commit e2b74fbde4
3 changed files with 254 additions and 206 deletions

View File

@@ -30,10 +30,13 @@ from sqlobject import *
from pyxmpp.message import Message
from jcl.model.account import Account, PresenceAccount
from jcl.jabber.component import Handler, DefaultSubscribeHandler, DefaultUnsubscribeHandler, DefaultPresenceHandler
from jcl.jabber.feeder import FeederComponent, Feeder, MessageSender, HeadlineSender
from jcl.jabber.component import Handler, DefaultSubscribeHandler, \
DefaultUnsubscribeHandler, DefaultPresenceHandler
from jcl.jabber.feeder import FeederComponent, Feeder, MessageSender, \
HeadlineSender
from jmc.model.account import MailAccount, IMAPAccount, POP3Account, SMTPAccount
from jmc.model.account import MailAccount, IMAPAccount, POP3Account, \
SMTPAccount
from jmc.lang import Lang
class MailComponent(FeederComponent):
@@ -47,19 +50,22 @@ class MailComponent(FeederComponent):
db_connection_str,
lang = Lang()):
"""Use FeederComponent behavior and setup feeder and sender
attributes
attributes.
"""
FeederComponent.__init__(self, \
jid, \
secret, \
server, \
port, \
FeederComponent.__init__(self,
jid,
secret,
server,
port,
db_connection_str,
lang=lang)
self.feeder = MailFeeder(self)
self.sender = MailSender(self)
self.account_manager.account_classes = (IMAPAccount, POP3Account, SMTPAccount)
self.msg_handlers += [SendMailMessageHandler(), RootSendMailMessageHandler()]
self.account_manager.account_classes = (IMAPAccount,
POP3Account,
SMTPAccount)
self.msg_handlers += [SendMailMessageHandler(),
RootSendMailMessageHandler()]
self.subscribe_handlers += [MailSubscribeHandler()]
self.unsubscribe_handlers += [MailUnsubscribeHandler()]
self.available_handlers += [DefaultPresenceHandler()]
@@ -76,10 +82,14 @@ class MailFeeder(Feeder):
def initialize_live_email(self, _account):
"""For live email checking account, mark emails received while
offline as read.
Return a boolean to continue mail checking or not (if waiting for password)"""
Return a boolean to continue mail checking or not
(if waiting for password).
"""
if _account.password is None:
if not _account.waiting_password_reply:
self.component.send_stanzas(self.component.account_manager.ask_password(_account, \
account_manager = self.component.account_manager
self.component.send_stanzas(\
account_manager.ask_password(_account,
_account.default_lang_class))
return False
try:
@@ -101,7 +111,8 @@ class MailFeeder(Feeder):
def feed(self, _account):
"""Check for new emails for given MailAccount and return a list of
those emails or a summary"""
those emails or a summary.
"""
self.__logger.debug("MailFeeder.feed")
result = []
if _account.first_check and _account.live_email_only:
@@ -115,7 +126,9 @@ class MailFeeder(Feeder):
if action != PresenceAccount.DO_NOTHING:
try:
if _account.password is None:
self.component.send_stanzas(self.component.account_manager.ask_password(_account, \
account_manager = self.component.account_manager
self.component.send_stanzas(\
account_manager.ask_password(_account,
_account.default_lang_class))
return result
self.__logger.debug("Checking " + _account.name)
@@ -123,12 +136,14 @@ class MailFeeder(Feeder):
+ "@" + _account.host)
_account.connect()
mail_list = _account.get_mail_list()
default_lang_class = _account.default_lang_class
if action == MailAccount.RETRIEVE:
# TODO : use generator (yield)
mail_index = _account.get_next_mail_index(mail_list)
while mail_index is not None:
(body, email_from) = _account.get_mail(mail_index)
result.append((_account.default_lang_class.new_mail_subject % (email_from), \
result.append((default_lang_class.new_mail_subject\
% (email_from),
body))
mail_index = _account.get_next_mail_index(mail_list)
elif action == MailAccount.DIGEST:
@@ -138,14 +153,16 @@ class MailFeeder(Feeder):
while mail_index is not None:
(tmp_body, from_email) = \
_account.get_mail_summary(mail_index)
body += tmp_body + "\n----------------------------------\n"
body += tmp_body
body += "\n----------------------------------\n"
mail_index = _account.get_next_mail_index(mail_list)
new_mail_count += 1
if body != "":
result.append((_account.default_lang_class.new_digest_subject % (new_mail_count), \
result.append((default_lang_class.new_digest_subject\
% (new_mail_count),
body))
else:
raise Exception("Unkown action: " + str(action)
raise Exception("Unkown action: " + str(action) \
+ "\nPlease reconfigure account.")
_account.disconnect()
_account.in_error = False
@@ -185,7 +202,8 @@ class MailHandler(Handler):
if accounts.count() == 0:
raise Exception()
else:
default_account = accounts.newClause(SMTPAccount.q.default_account == True)
default_account = accounts.newClause(\
SMTPAccount.q.default_account == True)
if default_account.count() > 0:
return default_account
else:
@@ -195,7 +213,8 @@ class MailHandler(Handler):
class SendMailMessageHandler(MailHandler):
def __init__(self):
MailHandler.__init__(self)
self.__logger = logging.getLogger("jmc.jabber.component.SendMailMessageHandler")
self.__logger = logging.getLogger(\
"jmc.jabber.component.SendMailMessageHandler")
def send_mail_result(self, message, lang, to_email):
return [Message(from_jid=message.get_to(),
@@ -206,23 +225,27 @@ class SendMailMessageHandler(MailHandler):
def handle(self, message, lang, accounts):
to_node = message.get_to().node
to_email = to_node.replace('%', '@', 1)
accounts[0].send_email(to_email, message.get_subject(), message.get_body())
accounts[0].send_email(to_email,
message.get_subject(),
message.get_body())
return self.send_mail_result(message, lang, to_email)
class RootSendMailMessageHandler(SendMailMessageHandler):
def __init__(self):
SendMailMessageHandler.__init__(self)
self.to_regexp = re.compile("^\s*(to|TO)\s*:\s*(?P<to_email>.*)")
self.__logger = logging.getLogger("jmc.jabber.component.RootSendMailMessageHandler")
self.__logger = logging.getLogger(\
"jmc.jabber.component.RootSendMailMessageHandler")
def filter(self, message):
name = message.get_to().node
bare_from_jid = unicode(message.get_from().bare())
accounts = Account.select(\
AND(Account.q.name == name, \
AND(Account.q.name == name,
Account.q.user_jid == bare_from_jid))
if accounts.count() != 1:
self.__logger.error("Account " + name + " for user " + bare_from_jid + " must be uniq")
self.__logger.error("Account " + name + " for user " + \
bare_from_jid + " must be uniq")
return accounts
def handle(self, message, lang, accounts):
@@ -239,7 +262,8 @@ class RootSendMailMessageHandler(SendMailMessageHandler):
message_body.append(line)
message_body.extend(lines)
if to_email is not None:
accounts[0].send_email(to_email, message.get_subject(), "".join(message_body))
accounts[0].send_email(to_email, message.get_subject(),
"\n".join(message_body))
return self.send_mail_result(message, lang, to_email)
else:
return [Message(from_jid=message.get_to(),

View File

@@ -560,15 +560,14 @@ class RootSendMailMessageHandler_TestCase(unittest.TestCase):
def test_filter(self):
account.hub.threadConnection = connectionForURI('sqlite://' + DB_URL)
account11 = SMTPAccount(user_jid = "user1@test.com", \
name = "account11", \
account11 = SMTPAccount(user_jid="user1@test.com",
name="account11",
jid="account11@jcl.test.com")
account12 = SMTPAccount(user_jid = "user1@test.com", \
name = "account12", \
account12 = SMTPAccount(user_jid="user1@test.com",
name="account12",
jid="account12@jcl.test.com")
message = Message(from_jid = "user1@test.com", \
to_jid = "account11@jcl.test.com", \
stanza_type = "normal", \
message = Message(from_jid="user1@test.com",
to_jid="account11@jcl.test.com",
body="message")
accounts = self.handler.filter(message)
self.assertEquals(accounts.count(), 1)
@@ -576,15 +575,14 @@ class RootSendMailMessageHandler_TestCase(unittest.TestCase):
def test_filter_wrong_dest(self):
account.hub.threadConnection = connectionForURI('sqlite://' + DB_URL)
account11 = SMTPAccount(user_jid = "user1@test.com", \
name = "account11", \
account11 = SMTPAccount(user_jid="user1@test.com",
name="account11",
jid="account11@jcl.test.com")
account12 = SMTPAccount(user_jid = "user1@test.com", \
name = "account12", \
account12 = SMTPAccount(user_jid="user1@test.com",
name="account12",
jid="account12@jcl.test.com")
message = Message(from_jid = "user1@test.com", \
to_jid = "user2%test.com@jcl.test.com", \
stanza_type = "normal", \
message = Message(from_jid="user1@test.com",
to_jid="user2%test.com@jcl.test.com",
body="message")
accounts = self.handler.filter(message)
self.assertEquals(accounts.count(), 0)
@@ -592,15 +590,14 @@ class RootSendMailMessageHandler_TestCase(unittest.TestCase):
def test_filter_wrong_user(self):
account.hub.threadConnection = connectionForURI('sqlite://' + DB_URL)
account11 = SMTPAccount(user_jid = "user1@test.com", \
name = "account11", \
account11 = SMTPAccount(user_jid="user1@test.com",
name="account11",
jid="account11@jcl.test.com")
account12 = SMTPAccount(user_jid = "user1@test.com", \
name = "account12", \
account12 = SMTPAccount(user_jid="user1@test.com",
name="account12",
jid="account12@jcl.test.com")
message = Message(from_jid = "user2@test.com", \
to_jid = "account11@jcl.test.com", \
stanza_type = "normal", \
message = Message(from_jid="user2@test.com",
to_jid="account11@jcl.test.com",
body="message")
accounts = self.handler.filter(message)
self.assertEquals(accounts.count(), 0)
@@ -611,7 +608,7 @@ class RootSendMailMessageHandler_TestCase(unittest.TestCase):
to_jid="jcl.test.com",
subject="message subject",
body="to: user@test.com\n" \
"message body")
"message body\nother line")
class MockSMTPAccount(object):
def send_email(self, to_email, subject, body):
self.to_email = to_email
@@ -621,7 +618,7 @@ class RootSendMailMessageHandler_TestCase(unittest.TestCase):
result = self.handler.handle(message, Lang.en, accounts)
self.assertEquals(accounts[0].to_email, "user@test.com")
self.assertEquals(accounts[0].subject, "message subject")
self.assertEquals(accounts[0].body, "message body")
self.assertEquals(accounts[0].body, "message body\nother line")
self.assertEquals(len(result), 1)
self.assertEquals(result[0].get_type(), None)
self.assertEquals(result[0].get_from(), "jcl.test.com")
@@ -683,7 +680,6 @@ class MailHandler_TestCase(unittest.TestCase):
jid = "account12@jcl.test.com")
message = Message(from_jid = "user1@test.com", \
to_jid = "user2%test.com@jcl.test.com", \
stanza_type = "normal", \
body = "message")
accounts = self.handler.filter(message)
self.assertNotEquals(accounts, None)
@@ -701,7 +697,6 @@ class MailHandler_TestCase(unittest.TestCase):
jid = "account12@jcl.test.com")
message = Message(from_jid = "user1@test.com", \
to_jid = "user2%test.com@jcl.test.com", \
stanza_type = "normal", \
body = "message")
accounts = self.handler.filter(message)
self.assertNotEquals(accounts, None)
@@ -719,7 +714,6 @@ class MailHandler_TestCase(unittest.TestCase):
jid = "account12@jcl.test.com")
message = Message(from_jid = "user1@test.com", \
to_jid = "user2test.com@jcl.test.com", \
stanza_type = "normal", \
body = "message")
accounts = self.handler.filter(message)
self.assertEquals(accounts, None)
@@ -735,7 +729,6 @@ class MailHandler_TestCase(unittest.TestCase):
jid = "account12@jcl.test.com")
message = Message(from_jid = "user3@test.com", \
to_jid = "user2%test.com@jcl.test.com", \
stanza_type = "normal", \
body = "message")
try:
accounts = self.handler.filter(message)

View File

@@ -79,7 +79,10 @@ class MYPOP3(poplib.POP3):
self.port = port
msg = "getaddrinfo returns an empty list"
self.sock = None
for res in socket.getaddrinfo(self.host, self.port, 0, socket.SOCK_STREAM):
for res in socket.getaddrinfo(self.host,
self.port,
0,
socket.SOCK_STREAM):
af, socktype, proto, canonname, sa = res
try:
self.sock = socket.socket(af, socktype, proto)
@@ -99,7 +102,8 @@ class MYPOP3(poplib.POP3):
self.welcome = self._getresp()
class MYPOP3_SSL(poplib.POP3_SSL):
def __init__(self, host, port = poplib.POP3_SSL_PORT, keyfile = None, certfile = None):
def __init__(self, host, port=poplib.POP3_SSL_PORT, keyfile=None,
certfile=None):
self.host = host
self.port = port
self.keyfile = keyfile
@@ -107,7 +111,8 @@ class MYPOP3_SSL(poplib.POP3_SSL):
self.buffer = ""
msg = "getaddrinfo returns an empty list"
self.sock = None
for res in socket.getaddrinfo(self.host, self.port, 0, socket.SOCK_STREAM):
for res in socket.getaddrinfo(self.host, self.port, 0,
socket.SOCK_STREAM):
af, socktype, proto, canonname, sa = res
try:
self.sock = socket.socket(af, socktype, proto)
@@ -129,14 +134,15 @@ class MYPOP3_SSL(poplib.POP3_SSL):
class MailAccount(PresenceAccount):
""" Wrapper to mail connection and action.
Abstract class, do not represent real mail connection type"""
Abstract class, do not represent real mail connection type.
"""
# Define constants
DIGEST = 1
RETRIEVE = 2
default_encoding = "utf-8"
possibles_actions = [PresenceAccount.DO_NOTHING, \
DIGEST, \
possibles_actions = [PresenceAccount.DO_NOTHING,
DIGEST,
RETRIEVE]
login = StringCol(default="")
@@ -172,28 +178,30 @@ class MailAccount(PresenceAccount):
if real_class is None:
real_class = cls
return PresenceAccount.get_register_fields(real_class) + \
[("login", "text-single", None, \
lambda field_value, default_func: account.mandatory_field(field_value), \
lambda : ""), \
("password", "text-private", None, password_post_func, \
lambda : ""), \
("host", "text-single", None, \
lambda field_value, default_func: account.mandatory_field(field_value), \
lambda : ""), \
("port", "text-single", None, \
account.int_post_func, \
lambda : real_class.get_default_port()), \
("ssl", "boolean", None, \
account.default_post_func, \
lambda : False), \
("store_password", "boolean", None, \
account.default_post_func, \
lambda : True), \
("live_email_only", "boolean", None, \
account.default_post_func, \
lambda : False), \
("interval", "text-single", None, \
account.int_post_func, \
[("login", "text-single", None,
lambda field_value, default_func: \
account.mandatory_field(field_value),
lambda : ""),
("password", "text-private", None, password_post_func,
lambda : ""),
("host", "text-single", None,
lambda field_value, default_func: \
account.mandatory_field(field_value),
lambda : ""),
("port", "text-single", None,
account.int_post_func,
lambda : real_class.get_default_port()),
("ssl", "boolean", None,
account.default_post_func,
lambda : False),
("store_password", "boolean", None,
account.default_post_func,
lambda : True),
("live_email_only", "boolean", None,
account.default_post_func,
lambda : False),
("interval", "text-single", None,
account.int_post_func,
lambda : 5)]
get_register_fields = classmethod(_get_register_fields)
@@ -205,17 +213,17 @@ class MailAccount(PresenceAccount):
def _get_presence_actions_fields(cls):
"""See PresenceAccount._get_presence_actions_fields
"""
return {'chat_action': (cls.possibles_actions, \
MailAccount.RETRIEVE), \
'online_action': (cls.possibles_actions, \
MailAccount.RETRIEVE), \
'away_action': (cls.possibles_actions, \
MailAccount.DIGEST), \
'xa_action': (cls.possibles_actions, \
MailAccount.DIGEST), \
'dnd_action': (cls.possibles_actions, \
MailAccount.DIGEST), \
'offline_action': (cls.possibles_actions, \
return {'chat_action': (cls.possibles_actions,
MailAccount.RETRIEVE),
'online_action': (cls.possibles_actions,
MailAccount.RETRIEVE),
'away_action': (cls.possibles_actions,
MailAccount.DIGEST),
'xa_action': (cls.possibles_actions,
MailAccount.DIGEST),
'dnd_action': (cls.possibles_actions,
MailAccount.DIGEST),
'offline_action': (cls.possibles_actions,
PresenceAccount.DO_NOTHING)}
get_presence_actions_fields = classmethod(_get_presence_actions_fields)
@@ -223,24 +231,26 @@ class MailAccount(PresenceAccount):
def get_decoded_part(self, part, charset_hint):
content_charset = part.get_content_charset()
result = u""
payload = part.get_payload(decode=True)
try:
if content_charset:
result = unicode(part.get_payload(decode=True).decode(content_charset))
result = unicode(payload.decode(content_charset))
else:
result = unicode(part.get_payload(decode=True).decode(MailAccount.default_encoding))
result = unicode(payload.decode(MailAccount.default_encoding))
except Exception, e:
try:
result = unicode(part.get_payload(decode=True))
result = unicode(payload)
except Exception, e:
try:
result = unicode(part.get_payload(decode=True).decode("iso-8859-1"))
result = unicode(payload.decode("iso-8859-1"))
except Exception, e:
if charset_hint is not None:
try:
result = unicode(part.get_payload(decode=True).decode(charset_hint))
result = unicode(payload.decode(charset_hint))
except Exception, e:
type, value, stack = sys.exc_info()
print >>sys.stderr, "".join(traceback.format_exception
print >>sys.stderr, \
"".join(traceback.format_exception
(type, value, stack, 5))
return result
@@ -254,18 +264,22 @@ class MailAccount(PresenceAccount):
try:
if from_decoded[i][1]:
charset_hint = from_decoded[i][1]
email_from += unicode(from_decoded[i][0].decode(from_decoded[i][1]))
email_from += unicode(from_decoded[i][0].decode(\
from_decoded[i][1]))
else:
email_from += unicode(from_decoded[i][0].decode(MailAccount.default_encoding))
email_from += unicode(from_decoded[i][0].decode(\
MailAccount.default_encoding))
except Exception,e:
try:
email_from += unicode(from_decoded[i][0])
except Exception, e:
try:
email_from += unicode(from_decoded[i][0].decode("iso-8859-1"))
email_from += unicode(from_decoded[i][0].decode(\
"iso-8859-1"))
except Exception, e:
type, value, stack = sys.exc_info()
print >>sys.stderr, "".join(traceback.format_exception
print >>sys.stderr, \
"".join(traceback.format_exception
(type, value, stack, 5))
result += email_from + u"\n"
@@ -275,29 +289,35 @@ class MailAccount(PresenceAccount):
try:
if subject_decoded[i][1]:
charset_hint = subject_decoded[i][1]
result += unicode(subject_decoded[i][0].decode(subject_decoded[i][1]))
result += unicode(subject_decoded[i][0].decode(\
subject_decoded[i][1]))
else:
result += unicode(subject_decoded[i][0].decode(MailAccount.default_encoding))
result += unicode(subject_decoded[i][0].decode(\
MailAccount.default_encoding))
except Exception,e:
try:
result += unicode(subject_decoded[i][0])
except Exception, e:
try:
result += unicode(subject_decoded[i][0].decode("iso-8859-1"))
result += unicode(subject_decoded[i][0].decode(\
"iso-8859-1"))
except Exception, e:
if charset_hint is not None:
try:
result += unicode(subject_decoded[i][0].decode(charset_hint))
result += unicode(subject_decoded[i][0].decode(\
charset_hint))
except Exception, e:
type, value, stack = sys.exc_info()
print >>sys.stderr, "".join(traceback.format_exception
print >>sys.stderr, \
"".join(traceback.format_exception
(type, value, stack, 5))
result += u"\n\n"
if include_body:
action = {
"text/plain" : lambda part: self.get_decoded_part(part, charset_hint),
"text/plain" : lambda part: \
self.get_decoded_part(part, charset_hint),
"text/html" : lambda part: "\n<<<HTML part skipped>>>\n"
}
for part in email_msg.walk():
@@ -352,8 +372,8 @@ class IMAPAccount(MailAccount):
if real_class is None:
real_class = cls
return MailAccount.get_register_fields(real_class) + \
[("mailbox", "text-single", None, \
account.default_post_func, \
[("mailbox", "text-single", None,
account.default_post_func,
lambda : "INBOX")]
get_register_fields = classmethod(_get_register_fields)
@@ -377,9 +397,9 @@ class IMAPAccount(MailAccount):
return MailAccount.get_status(self) + "/" + self.mailbox
def connect(self):
self.__logger.debug("Connecting to IMAP server " \
+ self.login + "@" + self.host + ":" + str(self.port) \
+ " (" + self.mailbox + "). SSL=" \
self.__logger.debug("Connecting to IMAP server "
+ self.login + "@" + self.host + ":" + str(self.port)
+ " (" + self.mailbox + "). SSL="
+ str(self.ssl))
if self.ssl:
self.connection = MYIMAP4_SSL(self.host, self.port)
@@ -389,7 +409,7 @@ class IMAPAccount(MailAccount):
self.connected = True
def disconnect(self):
self.__logger.debug("Disconnecting from IMAP server " \
self.__logger.debug("Disconnecting from IMAP server "
+ self.host)
self.connection.logout()
self.connected = False
@@ -407,7 +427,8 @@ class IMAPAccount(MailAccount):
typ, data = self.connection.select(self.mailbox, True)
typ, data = self.connection.fetch(index, '(RFC822)')
if typ == 'OK':
return self.format_message(email.message_from_string(data[0][1]))
return self.format_message(\
email.message_from_string(data[0][1]))
return u"Error while fetching mail " + str(index)
def get_mail_summary(self, index):
@@ -415,7 +436,8 @@ class IMAPAccount(MailAccount):
typ, data = self.connection.select(self.mailbox, True)
typ, data = self.connection.fetch(index, '(RFC822)')
if typ == 'OK':
return self.format_message_summary(email.message_from_string(data[0][1]))
return self.format_message_summary(\
email.message_from_string(data[0][1]))
return u"Error while fetching mail " + str(index)
def get_next_mail_index(self, mail_list):
@@ -451,9 +473,9 @@ class POP3Account(MailAccount):
type = property(get_type)
def connect(self):
self.__logger.debug("Connecting to POP3 server " \
+ self.login + "@" + self.host + ":" + str(self.port)\
+ ". SSL=" + str(self.ssl))
self.__logger.debug("Connecting to POP3 server "
+ self.login + "@" + self.host + ":" +
str(self.port) + ". SSL=" + str(self.ssl))
if self.ssl:
self.connection = MYPOP3_SSL(self.host, self.port)
else:
@@ -467,7 +489,7 @@ class POP3Account(MailAccount):
def disconnect(self):
self.__logger.debug("Disconnecting from POP3 server " \
self.__logger.debug("Disconnecting from POP3 server "
+ self.host)
self.connection.quit()
self.connected = False
@@ -486,7 +508,8 @@ class POP3Account(MailAccount):
except:
pass
if ret[0:3] == '+OK':
return self.format_message(email.message_from_string('\n'.join(data)))
return self.format_message(email.message_from_string(\
'\n'.join(data)))
return u"Error while fetching mail " + str(index)
def get_mail_summary(self, index):
@@ -497,7 +520,8 @@ class POP3Account(MailAccount):
except:
pass
if ret[0:3] == '+OK':
return self.format_message_summary(email.message_from_string('\n'.join(data)))
return self.format_message_summary(email.message_from_string(\
'\n'.join(data)))
return u"Error while fetching mail " + str(index)
def get_next_mail_index(self, mail_list):
@@ -547,28 +571,35 @@ class SMTPAccount(Account):
if real_class is None:
real_class = cls
return Account.get_register_fields(real_class) + \
[("login", "text-single", None, \
lambda field_value, default_func: account.mandatory_field(field_value), \
lambda : ""), \
("password", "text-private", None, password_post_func, \
lambda : ""), \
("host", "text-single", None, \
lambda field_value, default_func: account.mandatory_field(field_value), \
lambda : ""), \
("port", "text-single", None, \
account.int_post_func, \
lambda : real_class.get_default_port()), \
("ssl", "boolean", None, \
account.default_post_func, \
lambda : False), \
("default_from", "text-single", None, \
lambda field_value, default_func: account.mandatory_field(field_value), \
lambda : ""), \
("store_password", "boolean", None, \
account.default_post_func, \
[("login", "text-single", None,
lambda field_value, default_func: \
account.mandatory_field(field_value),
lambda : ""),
("password", "text-private", None, password_post_func,
lambda : ""),
("host", "text-single", None,
lambda field_value, default_func: \
account.mandatory_field(field_value),
lambda : ""),
("port", "text-single", None,
account.int_post_func,
lambda : real_class.get_default_port()),
("ssl", "boolean", None,
account.default_post_func,
lambda : False),
("default_from", "text-single", None,
lambda field_value, default_func: \
account.mandatory_field(field_value),
lambda : ""),
("store_password", "boolean", None,
account.default_post_func,
lambda : True)]
get_register_fields = classmethod(_get_register_fields)
def send_email(self, to_email, subject, body):
pass
self.__logger.debug("Sending email:\n"
"From: " + self.default_from + "\n" +
"To: " + to_email + "\n" +
"Subject: " + subject + "\n\n" +
body)