4teamwork/opengever.core — pull request #344 by lukasgraf (2014-06-27 13:26:59+00:00)
Title: Add missing upgrade step for metadata extraction

When extracting the document metadata into a separate behavior in PR #278 I forgot to add the corresponding upgrade step. This PR makes up for this and provides the necessary upgrade step.

In order to make sure the upgrade steps get executed in the right order I bumped the existing `opengever.document` upgrade step `2702` to `2703` and inserted this one at `2702`.

While implementing this upgrade step I stumbled upon a pretty nasty Dexterity bug:
- When a content type with fields in a **behavior** gets added, the default values are usually looked up when the AddForm is rendered
- If no default value adapter exists, and not value is given for the `default` keyword argument on the schema, this lookup falls back to `None` (the default value for the `default` keyword argument). Even though that `None` value may be filled into the form, it will get dropped from the request when submitting the add form.
- This results in the corresponding field **not being set** on the object - the attribute simply doesn't exist, it's not in `obj.__dict__`
- This case gets handled by Dexterity by doing a [dynamic default value lookup during attribute access in `DexterityContent.__getattr_`](https://github.com/plone/plone.dexterity/blob/1.x/plone/dexterity/content.py#L205). However, in Dexterity 1.x, this is only done for the base schema, but *not* for behavior schemas (subtypes). This has been [fixed in Dexterity 2.x](https://github.com/plone/plone.dexterity/blob/master/plone/dexterity/content.py#L260)

Therefore the first commit in this PR monkey-patches `DexterityContent` to apply this fix.

@phgross @maethu