[Zope-CMF] SVN: Products.GenericSetup/trunk/Products/GenericSetup/utils.py If exported value is None, attribute value is empty string (fixes a crash on contentrules configuration export)

Tres Seaver tseaver at palladion.com
Wed Mar 23 12:54:47 EDT 2011


-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

On 03/23/2011 12:26 PM, Laurence Rowe wrote:
> On 23 March 2011 16:22, Tres Seaver <tseaver at palladion.com> wrote:
>> -----BEGIN PGP SIGNED MESSAGE-----
>> Hash: SHA1
>>
>> On 03/23/2011 11:33 AM, Thomas Desvenain wrote:
>>> Log message for revision 121096:
>>>   If exported value is None, attribute value is empty string (fixes a crash on contentrules configuration export)
>>>
>>> Changed:
>>>   U   Products.GenericSetup/trunk/Products/GenericSetup/utils.py
>>>
>>> -=-
>>> Modified: Products.GenericSetup/trunk/Products/GenericSetup/utils.py
>>> ===================================================================
>>> --- Products.GenericSetup/trunk/Products/GenericSetup/utils.py        2011-03-23 15:23:20 UTC (rev 121095)
>>> +++ Products.GenericSetup/trunk/Products/GenericSetup/utils.py        2011-03-23 15:33:52 UTC (rev 121096)
>>> @@ -350,7 +350,12 @@
>>>
>>>          for a_name in a_names:
>>>              wrapper.write()
>>> -            a_value = escape(attrs[a_name].value.encode('utf-8'), quote=True)
>>> +            a_value = attrs[a_name].value
>>> +            if a_value is None:
>>> +                a_value = ""
>>> +            else:
>>> +                a_value = escape(a_value.encode('utf-8'), quote=True))
>>> +
>>>              wrapper.queue(' %s="%s"' % (a_name, a_value))
>>>
>>>          if self.childNodes:
>>
>>
>> We also need a test which exercises / asserts this new behavior.
> 
> In general in Zope, or at least with ZPT, None implies that an
> attribute should be dropped. Would it be possible to preserve that
> convention here?

That convention is not really as useful for XML data:  it tends to break
stuff on import:

  https://bugs.launchpad.net/zope-cmf/+bug/707927


Tres.
- -- 
===================================================================
Tres Seaver          +1 540-429-0999          tseaver at palladion.com
Palladion Software   "Excellence by Design"    http://palladion.com
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.10 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/

iEYEARECAAYFAk2KJdcACgkQ+gerLs4ltQ6XFwCeOaZXSBKxb3OsqS1KH1SX0HJg
oT0AoJfxXOa/kjqvqGWcODIFkoir4RJY
=xaS8
-----END PGP SIGNATURE-----


More information about the Zope-CMF mailing list