Dexterity and Audio
Well we've started using dexterity on some sites. We've created a nice little HTML5 wrapper for uploaded mp4 audio files. Doing so required really two things, a file field and a transcription field. We ran into a weird issue though. On upload of items when you check create object title from file name you get this:
Traceback (innermost last):
- Module ZPublisher.Publish, line 126, in publish
- Module ZPublisher.mapply, line 77, in mapply
- Module ZPublisher.Publish, line 46, in call_object
- Module plone.z3cform.layout, line 70, in __call__
- Module plone.z3cform.layout, line 54, in update
- Module plone.z3cform.fieldsets.extensible, line 59, in update
- Module plone.z3cform.patch, line 30, in GroupForm_update
- Module z3c.form.group, line 138, in update
- Module z3c.form.action, line 99, in execute
- Module z3c.form.button, line 315, in __call__
- Module z3c.form.button, line 170, in __call__
- Module plone.dexterity.browser.add, line 96, in handleAdd
- Module z3c.form.form, line 247, in createAndAdd
- Module plone.dexterity.browser.add, line 75, in add
- Module plone.dexterity.utils, line 142, in addContentToContainer
- Module plone.app.content.namechooser, line 34, in chooseName
- Module zope.component.hooks, line 104, in adapter_hook
- Module plone.app.dexterity.behaviors.filename, line 16, in __new__
- Module zope.component.hooks, line 104, in adapter_hook
- Module plone.dexterity.primary, line 24, in __init__
TypeError: ('Could not adapt', <Item at >, <InterfaceClass plone.rfc822.interfaces.IPrimaryFieldInfo>)
I couldn't find anything online about this so here we document the quick fix...
Fix this by:
- go to ZMI portal_types
- modify model source here to add in xmlns:marshal="http://namespaces.plone.org/supermodel/marshal"
- add marshal:primary="true" to namedfile that should be the name of file
Save it.. restart your clients and you should be good to go.
BTW our Behaviours has:
plone.app.dexterity.behaviors.exclfromnav.IExcludeFromNavigation
plone.app.versioningbehavior.behaviors.IVersionable
plone.app.dexterity.behaviors.filename.INameFromFileName
plone.app.dexterity.behaviors.metadata.IDublinCore
plone.app.relationfield.behavior.IRelatedItems
collective.dexteritytextindexer.behavior.IDexterityTextIndexer
plone.app.referenceablebehavior.referenceable.IReferenceable
plone.app.dexterity.behaviors.related.IRelatedItems
WIth a model of:
<model xmlns="http://namespaces.plone.org/supermodel/schema"
xmlns:marshal="http://namespaces.plone.org/supermodel/marshal">
<schema>
<field marshal:primary="true" name="file" type="plone.namedfile.field.NamedFile" >
<description />
<title>File</title>
</field>
<field name="transcription" type="plone.app.textfield.RichText">
<description>This field is for the transcription text of the media.</description>
<required>False</required>
<title>Transcription</title>
</field>
</schema>
</model>
