================================
Bugfix for address book entities
================================

There were some bugs when using entities.


Set up
======

Create an address book, a local adminstrator and a browser to access it:

>>> from icemac.addressbook.testing import create_addressbook, create_user
>>> ab = create_addressbook()
>>> create_user(
...     ab, ab, u'Ad', u'Min', u'ad@min.de', u'12345678', ('Administrator',))

>>> from z3c.etestbrowser.wsgi import ExtendedTestBrowser as Browser
>>> browser = Browser()

Edit entities as local administrator
====================================

A local administrator was not able to edit the entities.

Log in as the local administrator and navigate to the edit entities
section of the master data:

>>> from icemac.addressbook.testing import get_messages
>>> browser.open('http://localhost/++skin++AddressBook/ab')
>>> browser.getControl('User Name').value = 'ad@min.de'
>>> browser.getControl('Password').value = '12345678'
>>> browser.getControl('Log in').click()
>>> get_messages(browser)
['You have been logged-in successfully.']

>>> browser.getLink('Master data').click()
>>> browser.getLink('Entities').click()
>>> browser.url
'http://localhost/++skin++AddressBook/ab/++attribute++entities'
>>> print browser.contents
<!DOCTYPE ...
          <td>address book</td>
          ...
          <td>person</td>
          ...

Choice field values containing non ascii characters
===================================================

Choice field values could not contain non ascii characters.

Create a user defined choice field and a values containing a non ascii
character:

>>> browser.getLink('Edit fields', index=1).click()
>>> browser.url
'http://localh.../ab/++attribute++entities/icemac.addressbook.person.Person'
>>> browser.getLink('field').click()
>>> browser.getControl('type').displayValue = ['choice']
>>> browser.getControl('title').value = 'Ümläuttößt'
>>> browser.getControl('Add', index=0).click()
>>> get_messages(browser)
[]
>>> browser.getControl('value').value = 'Küche'
>>> browser.getControl('Add', index=1).click()
>>> get_messages(browser)
[u'"\xdcml\xe4utt\xf6\xdft" added.']
>>> browser.url
'http://localh.../ab/++attribute++entities/icemac.addressbook.person.Person'

The error occured when adding a new object for the entity with the user defined field (a person in our case):

>>> browser.getLink('Person list').click()
>>> browser.getLink('person').click()
>>> browser.getControl('Ümläuttößt').displayOptions
['no value', 'K\xc3\xbcche']
