[Checkins] SVN: Products.GenericSetup/trunk/Products/GenericSetup/ When the MailHost smtp_uid or smtp_pwd settings are None, export them
Maurits van Rees
m.van.rees at zestsoftware.nl
Wed Mar 3 10:14:35 EST 2010
Log message for revision 109614:
When the MailHost smtp_uid or smtp_pwd settings are None, export them
as empty string, to avoid an AttributeError during export.
This partly reverts my change r109595 by moving it specifically to the
_exportNode method of the MailHostXMLAdapter.
Changed:
U Products.GenericSetup/trunk/Products/GenericSetup/CHANGES.txt
U Products.GenericSetup/trunk/Products/GenericSetup/MailHost/exportimport.py
U Products.GenericSetup/trunk/Products/GenericSetup/utils.py
-=-
Modified: Products.GenericSetup/trunk/Products/GenericSetup/CHANGES.txt
===================================================================
--- Products.GenericSetup/trunk/Products/GenericSetup/CHANGES.txt 2010-03-03 14:23:33 UTC (rev 109613)
+++ Products.GenericSetup/trunk/Products/GenericSetup/CHANGES.txt 2010-03-03 15:14:34 UTC (rev 109614)
@@ -4,9 +4,8 @@
1.6.0 (unreleased)
------------------
-- Don't bomb out with an AttributeError when encoding an attribute
- with value None that is being exported; just use an empty string
- then.
+- When the MailHost smtp_uid or smtp_pwd settings are None, export
+ them as empty string, to avoid an AttributeError during export.
- Don't try to reinitialize a tool if an instance of the tool exists but the
desired tool class was not resolvable. Show a warning instead of failing.
Modified: Products.GenericSetup/trunk/Products/GenericSetup/MailHost/exportimport.py
===================================================================
--- Products.GenericSetup/trunk/Products/GenericSetup/MailHost/exportimport.py 2010-03-03 14:23:33 UTC (rev 109613)
+++ Products.GenericSetup/trunk/Products/GenericSetup/MailHost/exportimport.py 2010-03-03 15:14:34 UTC (rev 109614)
@@ -40,9 +40,15 @@
node = self._getObjectNode('object')
node.setAttribute('smtp_host', str(self.context.smtp_host))
node.setAttribute('smtp_port', str(self.context.smtp_port))
- node.setAttribute('smtp_uid', self.context.smtp_uid)
- node.setAttribute('smtp_pwd', self.context.smtp_pwd)
-
+ smtp_uid = self.context.smtp_uid
+ if smtp_uid is None:
+ # None would give an AttributeError during export.
+ smtp_uid = ''
+ node.setAttribute('smtp_uid', smtp_uid)
+ smtp_pwd = self.context.smtp_pwd
+ if smtp_pwd is None:
+ smtp_pwd = ''
+ node.setAttribute('smtp_pwd', smtp_pwd)
self._logger.info('Mailhost exported.')
return node
Modified: Products.GenericSetup/trunk/Products/GenericSetup/utils.py
===================================================================
--- Products.GenericSetup/trunk/Products/GenericSetup/utils.py 2010-03-03 14:23:33 UTC (rev 109613)
+++ Products.GenericSetup/trunk/Products/GenericSetup/utils.py 2010-03-03 15:14:34 UTC (rev 109614)
@@ -351,10 +351,7 @@
for a_name in a_names:
wrapper.write()
- a_value = attrs[a_name].value
- if a_value is None:
- a_value = ''
- a_value = escape(a_value.encode('utf-8'), quote=True)
+ a_value = escape(attrs[a_name].value.encode('utf-8'), quote=True)
wrapper.queue(' %s="%s"' % (a_name, a_value))
if self.childNodes:
More information about the checkins
mailing list