[ZCM] [ZC] 2263/ 3 Accept "ZPublisher.Converters inconsistent handling for lines and ulines conversion and empty field"
"Collector: Zope Bugs, Features, and Patches ..." <[email protected]>
| Newsgroups | gmane.comp.web.zope.devel.collector-monitor |
|---|---|
| Message-ID | <[email protected]> |
Issue #2263 Update (Accept) "ZPublisher.Converters inconsistent handling for lines and ulines conversion and empty field"
Status Accepted, Zope/bug+solution medium
To followup, visit:
http://www.zope.org/Collectors/Zope/2263
==============================================================
= Accept - Entry #3 by tseaver on Jan 11, 2007 12:48 pm
Status: Pending => Accepted
Supporters added: tseaver
Thanks for the report! I can see how to add a test for this, and
fix it.
________________________________________
= Comment - Entry #2 by pperegrina on Jan 11, 2007 8:03 am
Illustration of the difference:
LINES
>>> ''.splitlines()
[]
ULINES BUG
>>> u''.split('\n')
[u'']
ULINES SOLUTION
>>> u''.splitlines()
[]
________________________________________
= Request - Entry #1 by pperegrina on Jan 11, 2007 7:58 am
BUG
The conversion of fields of type lines and ulines is different when the field is empty.
1)lines
def field2lines(v):
if isinstance(v, (ListType, TupleType)):
result=[]
for item in v:
result.append(str(item))
return result
return field2text(v).splitlines()
2)ulines
class field2ulines(_unicode_converter):
def convert_unicode(self,v):
return field2utext.convert_unicode(v).split('\n')
field2ulines = field2ulines()
SOLUTION
in ulines, change :
field2utext.convert_unicode(v).split('\n')
to:
field2utext.convert_unicode(v).splitlines()
==============================================================