[Checkins] SVN: Products.GenericSetup/trunk/Products/GenericSetup/MailHost/ Switch policy: export defaults for 'smtp_queue{, _directory}' even if missing.

Tres Seaver tseaver at palladion.com
Mon Sep 19 13:02:31 EST 2011


Log message for revision 122849:
  Switch policy:  export defaults for 'smtp_queue{,_directory}' even if missing.

Changed:
  U   Products.GenericSetup/trunk/Products/GenericSetup/MailHost/exportimport.py
  U   Products.GenericSetup/trunk/Products/GenericSetup/MailHost/tests/test_exportimport.py

-=-
Modified: Products.GenericSetup/trunk/Products/GenericSetup/MailHost/exportimport.py
===================================================================
--- Products.GenericSetup/trunk/Products/GenericSetup/MailHost/exportimport.py	2011-09-19 17:59:03 UTC (rev 122848)
+++ Products.GenericSetup/trunk/Products/GenericSetup/MailHost/exportimport.py	2011-09-19 18:02:31 UTC (rev 122849)
@@ -49,15 +49,13 @@
         node.setAttribute('smtp_pwd', smtp_pwd)
 
         #Older MH instances won't have 'smtp_queue' in instance dict
-        if 'smtp_queue' in self.context.__dict__: 
-            smtp_queue = bool(self.context.smtp_queue)
-            node.setAttribute('smtp_queue', str(smtp_queue))
+        smtp_queue = bool(getattr(self.context, 'smtp_queue', False))
+        node.setAttribute('smtp_queue', str(smtp_queue))
             
-            smtp_queue_directory = self.context.smtp_queue_directory
-            if smtp_queue_directory is None:
-                smtp_queue_directory = ''
-            node.setAttribute('smtp_queue_directory',
-                              str(smtp_queue_directory))
+        qdir = getattr(self.context, 'smtp_queue_directory', '/tmp')
+        if qdir is None:
+            qdir = ''
+        node.setAttribute('smtp_queue_directory', str(qdir))
 
         self._logger.info('Mailhost exported.')
         return node

Modified: Products.GenericSetup/trunk/Products/GenericSetup/MailHost/tests/test_exportimport.py
===================================================================
--- Products.GenericSetup/trunk/Products/GenericSetup/MailHost/tests/test_exportimport.py	2011-09-19 17:59:03 UTC (rev 122848)
+++ Products.GenericSetup/trunk/Products/GenericSetup/MailHost/tests/test_exportimport.py	2011-09-19 18:02:31 UTC (rev 122849)
@@ -26,12 +26,6 @@
    smtp_uid=""/>
 """
 
-_MAILHOST_BODY_older_mh = """\
-<?xml version="1.0"?>
-<object name="foo_mailhost" meta_type="Mail Host" smtp_host="localhost"
-   smtp_port="25" smtp_pwd="" smtp_uid=""/>
-"""
-
 _MAILHOST_BODY_v2 = """\
 <?xml version="1.0"?>
 <object name="foo_mailhost" meta_type="Mail Host" smtp_host="localhost"
@@ -83,7 +77,7 @@
         mh = self._obj = MailHost('foo_mailhost')
         del mh.smtp_queue
         del mh.smtp_queue_directory
-        self._BODY = _MAILHOST_BODY_older_mh
+        self._BODY = _MAILHOST_BODY
 
 
 class MailHostXMLAdapterTestsWithQueue(BodyAdapterTestCase, unittest.TestCase):



More information about the checkins mailing list