Automatic title-to-id behavior
==============================

Say we have a 'Dinosaur' content type::

  >>> portal = layer['portal']
  >>> from plone.dexterity.fti import DexterityFTI
  >>> fti = DexterityFTI('dinosaur')
  >>> portal.portal_types._setObject('dinosaur', fti)
  'dinosaur'
  >>> fti.klass = 'plone.dexterity.content.Container'
  >>> fti.filter_content_types = False

We can declare that it supports the "name from title" behavior defined in
plone.app.content (normally this would be done via Generic Setup)::

  >>> fti.behaviors = ('plone.app.content.interfaces.INameFromTitle',
  ...                  'plone.app.dexterity.behaviors.metadata.IBasic')

Now let's fire up the browser and confirm that new content gets renamed
appropriately::

  >>> from plone.app.testing import TEST_USER_ID, TEST_USER_NAME, TEST_USER_PASSWORD, setRoles
  >>> setRoles(portal, TEST_USER_ID, ['Manager'])
  >>> import transaction; transaction.commit()
  >>> from plone.testing.z2 import Browser
  >>> browser = Browser(layer['app'])
  >>> browser.addHeader('Authorization', 'Basic %s:%s' % (TEST_USER_NAME, TEST_USER_PASSWORD,))

  >>> browser.open('http://nohost/plone/++add++dinosaur')
  >>> browser.getControl('Title').value = 'Brachiosaurus'
  >>> browser.getControl('Save').click()
  >>> browser.url
  'http://nohost/plone/brachiosaurus/view'


Title-to-id within a Dexterity container
----------------------------------------

Does it still work if we're adding content within a Dexterity container?  Let's
check::

  >>> browser.open('http://nohost/plone/brachiosaurus/++add++dinosaur')
  >>> browser.getControl('Title').value = 'Baby Brachiosaurus'
  >>> browser.getControl('Save').click()
  >>> browser.url
  'http://nohost/plone/brachiosaurus/baby-brachiosaurus/view'
