[Commits] (bkirsch) Added in getFirstAccount logic
commits at osafoundation.org
commits at osafoundation.org
Tue Aug 24 17:08:31 PDT 2004
Commit by: bkirsch
Modified files:
chandler/parcels/osaf/mail/debug.py 1.2 1.3
chandler/parcels/osaf/mail/imap.py 1.13 1.14
chandler/parcels/osaf/mail/sharing.py 1.3 1.4
chandler/parcels/osaf/mail/smtp.py 1.6 1.7
Log message:
Added in getFirstAccount logic
ViewCVS links:
http://cvs.osafoundation.org/index.cgi/chandler/parcels/osaf/mail/debug.py.diff?r1=text&tr1=1.2&r2=text&tr2=1.3
http://cvs.osafoundation.org/index.cgi/chandler/parcels/osaf/mail/imap.py.diff?r1=text&tr1=1.13&r2=text&tr2=1.14
http://cvs.osafoundation.org/index.cgi/chandler/parcels/osaf/mail/sharing.py.diff?r1=text&tr1=1.3&r2=text&tr2=1.4
http://cvs.osafoundation.org/index.cgi/chandler/parcels/osaf/mail/smtp.py.diff?r1=text&tr1=1.6&r2=text&tr2=1.7
Index: chandler/parcels/osaf/mail/imap.py
diff -u chandler/parcels/osaf/mail/imap.py:1.13 chandler/parcels/osaf/mail/imap.py:1.14
--- chandler/parcels/osaf/mail/imap.py:1.13 Thu Aug 19 17:33:12 2004
+++ chandler/parcels/osaf/mail/imap.py Tue Aug 24 17:08:29 2004
@@ -1,5 +1,5 @@
-__revision__ = "$Revision: 1.13 $"
-__date__ = "$Date: 2004/08/20 00:33:12 $"
+__revision__ = "$Revision: 1.14 $"
+__date__ = "$Date: 2004/08/25 00:08:29 $"
__copyright__ = "Copyright (c) 2004 Open Source Applications Foundation"
__license__ = "http://osafoundation.org/Chandler_0.1_license_terms.htm"
@@ -18,6 +18,7 @@
import logging as logging
import repository.util.UUID as UUID
import common as common
+import repository.item.Query as Query
#XXX: Need to make sure all the flags are in place to prevent a non-ssl session if
# ssl required
@@ -371,3 +372,23 @@
self.account.username, info)
self.log.info(str)
+
+
+def getFirstIMAPAccount():
+ """
+ This method returns the first IMAP Account found in the Repository.
+ The method will throw a C{IMAPException} if there is no C{IMAPAccount}
+ in the Repository.
+
+ @return C{IMAPAccount}
+ """
+ accountKind = Mail.MailParcel.getIMAPAccountKind()
+ account = None
+
+ for acc in Query.KindQuery().run([accountKind]):
+ account = acc
+
+ if account is None:
+ raise IMAPException("No IMAP Account exists in Repository")
+
+ return account
Index: chandler/parcels/osaf/mail/smtp.py
diff -u chandler/parcels/osaf/mail/smtp.py:1.6 chandler/parcels/osaf/mail/smtp.py:1.7
--- chandler/parcels/osaf/mail/smtp.py:1.6 Mon Aug 23 17:16:00 2004
+++ chandler/parcels/osaf/mail/smtp.py Tue Aug 24 17:08:29 2004
@@ -1,5 +1,5 @@
-__revision__ = "$Revision: 1.6 $"
-__date__ = "$Date: 2004/08/24 00:16:00 $"
+__revision__ = "$Revision: 1.7 $"
+__date__ = "$Date: 2004/08/25 00:08:29 $"
__copyright__ = "Copyright (c) 2004 Open Source Applications Foundation"
__license__ = "http://osafoundation.org/Chandler_0.1_license_terms.htm"
@@ -17,6 +17,7 @@
import message as message
import osaf.contentmodel.mail.Mail as Mail
import repository.util.UUID as UUID
+import repository.item.Query as Query
import mx.DateTime as DateTime
try:
@@ -133,7 +134,7 @@
from_addr = self.mailMessage.fromAddress.emailAddress
finally:
- self.restorePreviousView()
+ self.restorePreviousView()
factory = ChandlerESMTPSenderFactory(username, password, from_addr, to_addrs, msg, d,
retries, sslContext, heloFallback, authRequired, useSSL, useSSL)
@@ -369,3 +370,44 @@
self.account.setPinned()
self.mailMessage.setPinned()
+
+def getDefaultSMTPAccount():
+ """
+ This method returns a tuple containing:
+ 1. the first C{SMTPAccount} account in the Repository.
+ 2. The ReplyTo C{EmailAddress} associated with the C{SMTPAccounts}
+ parent which will either be a POP or IMAP Acccount.
+
+ The method will throw a C{SMTPException} if:
+ 1. No C{SMTPAccount} in the Repository
+ 2. No parent account associated with the C{SMTPAccount}
+ 3. The replyToAddress of the parent account is None
+
+ @return C{tuple} in the form (C{SMTPAccount}, C{EmailAddress})
+ """
+ accountKind = Mail.MailParcel.getSMTPAccountKind()
+ account = None
+ replyToAddress = None
+
+ """Get the first SMTP Account"""
+ for acc in Query.KindQuery().run([accountKind]):
+ account = acc
+ break
+
+ if account is None:
+ raise SMTPException("No SMTP Account found")
+
+ accList = account.accounts
+
+ if accList is None:
+ raise SMTPException("No Parent Accounts associated with the SMTP account. Can not get replyToAddress.")
+
+ """Get the first IMAP Account"""
+ for parentAccount in accList:
+ replyToAddress = parentAccount.replyToAddress
+ break
+
+ if replyToAddress is None:
+ raise SMTPException("No replyToAddress found for IMAP Account")
+
+ return (account, replyToAddress)
Index: chandler/parcels/osaf/mail/debug.py
diff -u chandler/parcels/osaf/mail/debug.py:1.2 chandler/parcels/osaf/mail/debug.py:1.3
--- chandler/parcels/osaf/mail/debug.py:1.2 Tue Aug 24 16:19:38 2004
+++ chandler/parcels/osaf/mail/debug.py Tue Aug 24 17:08:29 2004
@@ -1,5 +1,5 @@
-__revision__ = "$Revision: 1.2 $"
-__date__ = "$Date: 2004/08/24 23:19:38 $"
+__revision__ = "$Revision: 1.3 $"
+__date__ = "$Date: 2004/08/25 00:08:29 $"
__copyright__ = "Copyright (c) 2004 Open Source Applications Foundation"
__license__ = "http://osafoundation.org/Chandler_0.1_license_terms.htm"
@@ -24,12 +24,7 @@
sharing.SMTPInvitationSender("http://test.com", ['brian at localhost', 'bkirsch at osafoundation.org']).sendInvitation()
def sendSMTPMessage():
- accountKind = Mail.MailParcel.getSMTPAccountKind()
- account = None
-
- for acc in Query.KindQuery().run([accountKind]):
- account = acc
- break
+ account, replyToAddress = smtp.getDefaultSMTPAccount()
m = Mail.MailMessage()
@@ -39,29 +34,13 @@
ea1 = Mail.EmailAddress()
ea1.emailAddress = "bkirsch at osafoundation.org"
- #ea1.fullName = "Brian Kirsch"
+ ea1.fullName = "Brian Kirsch"
- ea2 = Mail.EmailAddress()
- ea2.emailAddress = "bbi.com"
- #ea2.fullName = "Brian Kirsch"
-
- ea3 = Mail.EmailAddress()
- ea3.emailAddress = "bill at test.com"
-
- ea4 = Mail.EmailAddress()
- ea4.emailAddress = "brian at yahoo.com"
- #ea.fullName = "Brian Kirsch"
+ m.toAddress.append(ea)
m.toAddress.append(ea1)
- #m.toAddress.append(ea2)
- #m.toAddress.append(ea3)
- #m.toAddress.append(ea4)
- # m.toAddress.append(ea1)
- #m.ccAddress.append(ea2)
- #m.bccAddress.append(ea)
- m.fromAddress = ea
- #m.replyToAddress = ea
+ m.fromAddress = replyToAddress
m.subject = "This is a Test From SMTPSenderAction"
m.body = message.strToText(m, "body", "This is some body Text")
Index: chandler/parcels/osaf/mail/sharing.py
diff -u chandler/parcels/osaf/mail/sharing.py:1.3 chandler/parcels/osaf/mail/sharing.py:1.4
--- chandler/parcels/osaf/mail/sharing.py:1.3 Tue Aug 24 16:19:38 2004
+++ chandler/parcels/osaf/mail/sharing.py Tue Aug 24 17:08:29 2004
@@ -12,7 +12,6 @@
import message as message
import osaf.contentmodel.mail.Mail as Mail
import repository.persistence.RepositoryView as RepositoryView
-import repository.item.Query as Query
import repository.util.UUID as UUID
import mx.DateTime as DateTime
@@ -94,8 +93,6 @@
messageText = self.__createMessageText()
- print "Message Text:\n", messageText
-
d = defer.Deferred().addCallbacks(self.__invitationSuccessCheck, self.__invitationFailure)
msg = StringIO(messageText)
@@ -156,26 +153,5 @@
return messageObject.as_string()
def __getData(self):
- accountKind = Mail.MailParcel.getSMTPAccountKind()
-
- """Get the first SMTP Account"""
- for acc in Query.KindQuery().run([accountKind]):
- self.account = acc
- break
-
- if self.account is None:
- raise SharingException("No SMTP Account found to send invitation with")
-
- imapList = self.account.accounts
-
- if imapList is None:
- raise SharingException("No IMAP Accounts associated with the SMTP account. Can not get replyToAddress.")
-
- """Get the first IMAP Account"""
- for imapAccount in imapList:
- self.from_addr = imapAccount.replyToAddress.emailAddress
- break
-
- if self.from_addr is None:
- raise SharingException("No replyToAddress found for IMAP Account")
-
+ self.account, replyToAddress = smtp.getDefaultSMTPAccount()
+ self.from_addr = replyToAddress.emailAddress
More information about the Commits
mailing list