[Zope3-checkins] SVN: Zope3/trunk/src/zwiki/ Removed hardcoded
"utf-8" and added more tests
Dmitry Vasiliev
dima at hlabs.spb.ru
Fri Nov 11 03:24:48 EST 2005
Log message for revision 40046:
Removed hardcoded "utf-8" and added more tests
Changed:
U Zope3/trunk/src/zwiki/tests/test_wikimail.py
U Zope3/trunk/src/zwiki/wikipage.py
-=-
Modified: Zope3/trunk/src/zwiki/tests/test_wikimail.py
===================================================================
--- Zope3/trunk/src/zwiki/tests/test_wikimail.py 2005-11-11 00:58:32 UTC (rev 40045)
+++ Zope3/trunk/src/zwiki/tests/test_wikimail.py 2005-11-11 08:24:47 UTC (rev 40046)
@@ -155,20 +155,20 @@
page = WikiPage()
page_sub = MailSubscriptions(page)
page_sub.context.__annotations__[SubscriberKey] = ('blah at bar.com',)
- wiki['page1'] = page
- page.source = 'Hello World!'
- self.assertEqual('wiki at zope3.org',
+ wiki[u'page1 \u0410'] = page
+ page.source = u'Hello World! \u0410'
+ self.assertEqual('wiki at zope3.org',
mail_result[-1][0])
self.assertEqual(('blah at bar.com', 'foo at bar.com'), mail_result[-1][1])
message = email.message_from_string(mail_result[-1][2])
self.assert_(len(message) >= 3)
self.assertEqual(decode_header(message["Subject"])[0][0],
- "Modified: page1")
+ "Modified: page1 \xd0\x90")
self.assertEqual(message["From"], "wiki at zope3.org")
self.assertEqual(message["To"], "wiki at zope3.org")
self.assertEqual(message.get_payload(decode=True),
- "\n??changed:\n-\n+Hello World!\n")
+ "\n??changed:\n-\n+Hello World! \xd0\x90\n")
page.source = 'Hello New World!'
self.assertEqual('wiki at zope3.org',
@@ -178,11 +178,11 @@
message = email.message_from_string(mail_result[-1][2])
self.assert_(len(message) >= 3)
self.assertEqual(decode_header(message["Subject"])[0][0],
- "Modified: page1")
+ "Modified: page1 \xd0\x90")
self.assertEqual(message["From"], "wiki at zope3.org")
self.assertEqual(message["To"], "wiki at zope3.org")
self.assertEqual(message.get_payload(decode=True),
- "\n??changed:\n-Hello World!\n+Hello New World!\n")
+ "\n??changed:\n-Hello World! \xd0\x90\n+Hello New World!\n")
def test_suite():
Modified: Zope3/trunk/src/zwiki/wikipage.py
===================================================================
--- Zope3/trunk/src/zwiki/wikipage.py 2005-11-11 00:58:32 UTC (rev 40045)
+++ Zope3/trunk/src/zwiki/wikipage.py 2005-11-11 08:24:47 UTC (rev 40046)
@@ -356,7 +356,7 @@
self.handleRemoved(event.object)
def handleAdded(self, object):
- subject = 'Added: '+zapi.name(object)
+ subject = 'Added: ' + zapi.name(object)
emails = self.getAllSubscribers(object)
body = object.source
self.mail(emails, subject, body)
@@ -364,13 +364,13 @@
def handleModified(self, event):
object = event.object
if zapi.name(object) is not None:
- subject = 'Modified: '+zapi.name(object)
+ subject = 'Modified: ' + zapi.name(object)
emails = self.getAllSubscribers(object)
body = textdiff(event.oldSource, object.source)
self.mail(emails, subject, body)
def handleRemoved(self, object):
- subject = 'Removed: '+zapi.name(object)
+ subject = 'Removed: ' + zapi.name(object)
emails = self.getAllSubscribers(object)
body = subject
self.mail(emails, subject, body)
@@ -385,16 +385,15 @@
def mail(self, emails, subject, body):
"""Mail out the Wiki change message."""
- if not emails:
- return
- msg = self._getMessage(subject, body)
- mail_delivery = zapi.getUtility(IMailDelivery,
- 'wiki-delivery')
- mail_delivery.send(self.fromaddr, emails, msg)
+ if emails:
+ msg = self._getMessage(subject, body)
+ mail_delivery = zapi.getUtility(IMailDelivery, 'wiki-delivery')
+ mail_delivery.send(self.fromaddr, emails, msg)
def _getMessage(self, subject, body):
- message = MIMEText(body.encode("utf-8"), "plain", self.encoding)
- message["Subject"] = Header(subject.encode("utf-8"), self.encoding)
+ message = MIMEText(body.encode(self.encoding), "plain", self.encoding)
+ message["Subject"] = Header(
+ subject.encode(self.encoding), self.encoding)
message["From"] = self.fromaddr
message["To"] = self.fromaddr
return message.as_string()
More information about the Zope3-Checkins
mailing list