Metadata on objects
===================

The default dublin core implementation from CMF is used by dexterity in the
Dublin Core behaviour, a subset of which is available in the Ownership, Basic
Metadata, etc behaviours.

When we create a dexterity content type::

    >>> portal = layer['portal']
    >>> from plone.dexterity.fti import DexterityFTI
    >>> fti = DexterityFTI('metadatad_type')
    >>> fti.behaviors = ('plone.app.dexterity.behaviors.metadata.IDublinCore',)
    >>> portal.portal_types._setObject('metadatad_type', fti)
    'metadatad_type'
    >>> schema = fti.lookupSchema()

If we access the site as an admin TTW::

    >>> 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,))

We can see this type in the addable types at the root of the site::

    >>> browser.open("http://nohost/plone/folder_factories")
    >>> "metadatad_type" in browser.contents
    True
    >>> browser.getControl("metadatad_type").click()
    >>> browser.getControl("Add").click()
    >>> browser.getControl(name="form.widgets.IDublinCore.title").value = "My Object"
    >>> browser.getControl(name="form.widgets.IDublinCore.description").value = "Lorem ipsum"
    >>> browser.getControl(name="form.buttons.save").click()
    >>> browser.url
    'http://nohost/plone/metadatad_type/view'

The creator of the object is the current user::

    >>> "http://nohost/plone/author/test_user_1_" in browser.contents
    True
    >>> md = portal.metadatad_type
    >>> md.Creator()
    'test_user_1_'

The modified and creation dates are set correctly::

    >>> md.ModificationDate()[0:16] == md.CreationDate()[0:16]
    True
    >>> from DateTime import DateTime
    >>> DateTime() > DateTime(md.CreationDate())
    True

