Ticket #14275 (new Bug)

Opened 21 months ago

Unicode handling with memberdata extender and zope.formlib

Reported by: ajung Owned by:
Priority: minor Milestone: 4.x
Component: Unknown Version: 4.3
Keywords: Cc:

Description

Plone 4.3.3:

we extended the memberdata schema with 'cv' field

cv = schema.Text(

title=_(u"label_userdataschema_cv"), description=_(u"help_userdataschema_cv"), required=False, )

As part of the migration we added the a unicode string to the related member object using member.setMemberProperties().

Rendering the @@user-information view for this field fails with a UnicodeError because Plone seems to convert the unicode into UTF8 in very case and the renderElement of zope.formlib fails.

As a workaround we are using the following lame monkey patch:

def renderElement(tag, kw):

contents = kw.pop('contents', None) if contents is not None:

# Do not quote contents, since it often contains generated HTML. try:

return u"%s>%s</%s>" % (renderTag(tag, kw), contents, tag)

except UnicodeError:

return u"%s>%s</%s>" % (renderTag(tag, kw), unicode(contents, 'utf-8'), tag)

else:

return renderTag(tag, kw) + " />"

import zope.formlib.widget zope.formlib.widget.renderElement.func_code = renderElement.func_code

The baseline is: you can not extend the memberschema out of the box if the value of a field contains non-ascii characters

Note: See TracTickets for help on using tickets.