Re: supermodel + schemaeditor: trailing line field in Choice values entered

Sean Upton <[email protected]>
Newsgroups gmane.comp.web.zope.plone.devel
Message-ID <CANjV-2OtPi760X5k-dfuHRaHx1ePCOngaDj=sfROSwq6EzX2dw@mail.gmail.com>
On Mon, Dec 23, 2013 at 10:53 AM, Sean Upton <[email protected]> wrote:
> Folks,
>
> plone.supermodel chokes parsing schema created by plone.schemaeditor
> when Choice field is input with one or more trailing line feeds at the
> end of the values.
>
> This leads to serialized XML that looks like:
>
>       <values>
>         <element>A</element>
>         <element>B</element>
>         <element></element>
>       </values>
>
> Attempting to parse this breaks every time on
> ChoiceHandler._constructField() trying to deal with a NoneType value.
> http://pastie.org/8571776
>
> Where should I look to fix this, in supermodel, schemaeditor, or both?
>
>   (1) schemaeditor should strip() the input.
>
>   (2) supermodel should, on export, omit blank terms.
>
>   (3) supermodel should, on import, ignore NoneType values

Another wrinkle to #2/#3: IIRC, zope.schema vocabularies support empty
strings as a valid term.  Not sure what to do with that, but err on
the side of allowing it.  Instead of having the term parsed into a
None value, parse it to ''?

Sean

------------------------------------------------------------------------------
Rapidly troubleshoot problems before they affect your business. Most IT 
organizations don't have a clear picture of how application performance 
affects their revenue. With AppDynamics, you get 100% visibility into your 
Java,.NET, & PHP application. Start your 15-day FREE TRIAL of AppDynamics Pro!
http://pubads.g.doubleclick.net/gampad/clk?id=84349831&iu=/4140/ostg.clktrk
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.