Login | Register For Free | Help
Search for: (Advanced)

Mailing List Archive: Zope: CMF

Re: SVN: Products.GenericSetup/trunk/Products/GenericSetup/ Don't bomb out with an AttributeError when encoding an attribute

 

 

Zope cmf RSS feed   Index | Next | Previous | View Threaded


m.van.rees at zestsoftware

Mar 3, 2010, 3:24 AM

Post #1 of 3 (466 views)
Permalink
Re: SVN: Products.GenericSetup/trunk/Products/GenericSetup/ Don't bomb out with an AttributeError when encoding an attribute

Wichert Akkerman, on 2010-03-03:
> On 3/3/10 11:48 , Maurits van Rees wrote:
>> Log message for revision 109595:
>> Don't bomb out with an AttributeError when encoding an attribute
>> with value None that is being exported; just use an empty string then.
>> Case in point: create a Plone Site, set the MailHost settings through
>> the Site Setup; an export of the mailhost settings would then fail if
>> some of the values (e.g. smtp_uid) were blank (None).
>
> Might I suggest not exporting anything instead of an empty string? There
> is a big difference between None and "".

I just tried that; this would generate a file like this:

<object name="foo_mailhost" meta_type="Mail Host" smtp_host="localhost"
smtp_port="25"/>

An import of this file in a Plone Site worked. But then the export
would become this:

<object name="foo_mailhost" meta_type="Mail Host" smtp_host="localhost"
smtp_port="25" smtp_pwd="" smtp_uid=""/>

So then an import of an export gives a slightly different result; and
the tests do not like that, failing either in test_body_set or in
test_body_get, depending on how you define as self._BODY in
MailHost/tests/test_exportimport.py

So I say we keep it like this.


Alternatively, Plone could be fixed to not set None values in the mail
settings (in plone.app.controlpanel). But I think this general fix in
GenericSetup is fine.

--
Maurits van Rees | http://maurits.vanrees.org/
Work | http://zestsoftware.nl/
What are you going to create today?

_______________________________________________
Zope-CMF maillist - Zope-CMF [at] zope
https://mail.zope.org/mailman/listinfo/zope-cmf

See https://bugs.launchpad.net/zope-cmf/ for bug reports and feature requests


y.2010 at wcm-solutions

Mar 3, 2010, 4:18 AM

Post #2 of 3 (448 views)
Permalink
Re: SVN: Products.GenericSetup/trunk/Products/GenericSetup/ Don't bomb out with an AttributeError when encoding an attribute [In reply to]

Maurits van Rees wrote:
> Wichert Akkerman, on 2010-03-03:
>> On 3/3/10 11:48 , Maurits van Rees wrote:
>>> Log message for revision 109595:
>>> Don't bomb out with an AttributeError when encoding an attribute
>>> with value None that is being exported; just use an empty string then.
>>> Case in point: create a Plone Site, set the MailHost settings through
>>> the Site Setup; an export of the mailhost settings would then fail if
>>> some of the values (e.g. smtp_uid) were blank (None).
>>
>> Might I suggest not exporting anything instead of an empty string? There
>> is a big difference between None and "".
>
> I just tried that; this would generate a file like this:
>
> <object name="foo_mailhost" meta_type="Mail Host" smtp_host="localhost"
> smtp_port="25"/>
>
> An import of this file in a Plone Site worked. But then the export
> would become this:
>
> <object name="foo_mailhost" meta_type="Mail Host" smtp_host="localhost"
> smtp_port="25" smtp_pwd="" smtp_uid=""/>
>
> So then an import of an export gives a slightly different result; and
> the tests do not like that, failing either in test_body_set or in
> test_body_get, depending on how you define as self._BODY in
> MailHost/tests/test_exportimport.py
>
> So I say we keep it like this.
>
>
> Alternatively, Plone could be fixed to not set None values in the mail
> settings (in plone.app.controlpanel). But I think this general fix in
> GenericSetup is fine.

I think the fix is in the wrong place. I doubt None is a valid value for
a DOM attribute. So instead of working around invalid data we should
make sure only valid data is written to the DOM.

AFAICS MailHostXMLAdapter._exportNode is the right place to fix this.

Cheers, Yuppie
_______________________________________________
Zope-CMF maillist - Zope-CMF [at] zope
https://mail.zope.org/mailman/listinfo/zope-cmf

See https://bugs.launchpad.net/zope-cmf/ for bug reports and feature requests


m.van.rees at zestsoftware

Mar 3, 2010, 7:15 AM

Post #3 of 3 (449 views)
Permalink
Re: SVN: Products.GenericSetup/trunk/Products/GenericSetup/ Don't bomb out with an AttributeError when encoding an attribute [In reply to]

yuppie, on 2010-03-03:
>>> On 3/3/10 11:48 , Maurits van Rees wrote:
>>>> Log message for revision 109595:
>>>> Don't bomb out with an AttributeError when encoding an attribute
>>>> with value None that is being exported; just use an empty string then.
>>>> Case in point: create a Plone Site, set the MailHost settings through
>>>> the Site Setup; an export of the mailhost settings would then fail if
>>>> some of the values (e.g. smtp_uid) were blank (None).
>>>
(...)
> I think the fix is in the wrong place. I doubt None is a valid value for
> a DOM attribute. So instead of working around invalid data we should
> make sure only valid data is written to the DOM.
>
> AFAICS MailHostXMLAdapter._exportNode is the right place to fix this.

Makes sense. Done in r109614.

--
Maurits van Rees | http://maurits.vanrees.org/
Work | http://zestsoftware.nl/
What are you going to create today?

_______________________________________________
Zope-CMF maillist - Zope-CMF [at] zope
https://mail.zope.org/mailman/listinfo/zope-cmf

See https://bugs.launchpad.net/zope-cmf/ for bug reports and feature requests

Zope cmf RSS feed   Index | Next | Previous | View Threaded
 
 


Interested in having your list archived? Contact Gossamer Threads
 
  Web Applications & Managed Hosting Powered by Gossamer Threads Inc.