Update registration fields post_func and default_func semantic
darcs-hash:20070324105851-86b55-5accb21c34bb40460721cbc898a073bbb2d0e87b.gz
This commit is contained in:
@@ -163,29 +163,43 @@ class MailAccount(PresenceAccount):
|
|||||||
def _get_register_fields(cls):
|
def _get_register_fields(cls):
|
||||||
"""See Account._get_register_fields
|
"""See Account._get_register_fields
|
||||||
"""
|
"""
|
||||||
def password_post_func(password):
|
def password_post_func(password, default_func):
|
||||||
if password is None or password == "":
|
if password is None or password == "":
|
||||||
return None
|
return None
|
||||||
return password
|
return password
|
||||||
|
|
||||||
return PresenceAccount.get_register_fields() + \
|
return PresenceAccount.get_register_fields() + \
|
||||||
[("login", "text-single", None, account.string_not_null_post_func, \
|
[("login", "text-single", None, \
|
||||||
account.mandatory_field), \
|
lambda field_value, default_func: account.mandatory_field("login", \
|
||||||
|
field_value, \
|
||||||
|
default_func), \
|
||||||
|
lambda : ""), \
|
||||||
("password", "text-private", None, password_post_func, \
|
("password", "text-private", None, password_post_func, \
|
||||||
(lambda field_name: None)), \
|
lambda : ""), \
|
||||||
("host", "text-single", None, account.string_not_null_post_func, \
|
("host", "text-single", None, \
|
||||||
account.mandatory_field), \
|
lambda field_value, default_func: account.mandatory_field("host", \
|
||||||
("port", "text-single", None, account.int_post_func, \
|
field_value, \
|
||||||
account.mandatory_field), \
|
default_func), \
|
||||||
("ssl", "boolean", None, account.default_post_func, \
|
lambda : ""), \
|
||||||
(lambda field_name: None)), \
|
("port", "text-single", None, \
|
||||||
("store_password", "boolean", None, account.default_post_func, \
|
account.int_post_func, \
|
||||||
(lambda field_name: True)), \
|
lambda : cls.get_default_port()), \
|
||||||
("live_email_only", "boolean", None, account.default_post_func, \
|
("ssl", "boolean", None, \
|
||||||
lambda field_name: False)]
|
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)]
|
||||||
|
|
||||||
get_register_fields = classmethod(_get_register_fields)
|
get_register_fields = classmethod(_get_register_fields)
|
||||||
|
|
||||||
|
def _get_default_port(cls):
|
||||||
|
return 42
|
||||||
|
get_default_port = classmethod(_get_default_port)
|
||||||
|
|
||||||
def _get_presence_actions_fields(cls):
|
def _get_presence_actions_fields(cls):
|
||||||
"""See PresenceAccount._get_presence_actions_fields
|
"""See PresenceAccount._get_presence_actions_fields
|
||||||
"""
|
"""
|
||||||
@@ -334,11 +348,17 @@ class IMAPAccount(MailAccount):
|
|||||||
return password
|
return password
|
||||||
|
|
||||||
return MailAccount.get_register_fields() + \
|
return MailAccount.get_register_fields() + \
|
||||||
[("mailbox", "text-single", None, account.string_not_null_post_func, \
|
[("mailbox", "text-single", None, \
|
||||||
(lambda field_name: "INBOX"))]
|
account.default_post_func, \
|
||||||
|
lambda : "INBOX")]
|
||||||
|
|
||||||
get_register_fields = classmethod(_get_register_fields)
|
get_register_fields = classmethod(_get_register_fields)
|
||||||
|
|
||||||
|
def _get_default_port(cls):
|
||||||
|
"""Return default IMAP server port"""
|
||||||
|
return 143
|
||||||
|
|
||||||
|
get_default_port = classmethod(_get_default_port)
|
||||||
|
|
||||||
def _init(self, *args, **kw):
|
def _init(self, *args, **kw):
|
||||||
MailAccount._init(self, *args, **kw)
|
MailAccount._init(self, *args, **kw)
|
||||||
@@ -413,6 +433,12 @@ class POP3Account(MailAccount):
|
|||||||
MailAccount._init(self, *args, **kw)
|
MailAccount._init(self, *args, **kw)
|
||||||
self.__logger = logging.getLogger("jmc.model.account.POP3Account")
|
self.__logger = logging.getLogger("jmc.model.account.POP3Account")
|
||||||
|
|
||||||
|
def _get_default_port(cls):
|
||||||
|
"""Return default POP3 server port"""
|
||||||
|
return 110
|
||||||
|
|
||||||
|
get_default_port = classmethod(_get_default_port)
|
||||||
|
|
||||||
def get_type(self):
|
def get_type(self):
|
||||||
if self.ssl:
|
if self.ssl:
|
||||||
return "pop3s"
|
return "pop3s"
|
||||||
|
|||||||
@@ -489,3 +489,4 @@ class MailComponent_TestCase(unittest.TestCase):
|
|||||||
self.assertTrue(account11.marked_all_as_read)
|
self.assertTrue(account11.marked_all_as_read)
|
||||||
self.assertEquals(len(self.comp.stream.sent), 1)
|
self.assertEquals(len(self.comp.stream.sent), 1)
|
||||||
del account.hub.threadConnection
|
del account.hub.threadConnection
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user