Bug or Feature - Enable IRichtext Behavior on DX Type File?

If i enable the Richtext Behavior for Files (Video with a HTML Textfield for explanation is needed). The View of Video is broken, only when i click in the Editbar on "View". The IPrimaryFieldInfo return the RichtextField not the FileField. I'm not sure, is this a Bug or the normal behavior?

plone.app.contenttypes set the primaryinfo in the schema for Files:

<field
     name="file" type="plone.namedfile.field.NamedBlobFile"
     marshal:primary="true">
      <description />
      <title i18n:translate="label_file">File</title>
 </field>

Can you be more specific in how the view is broken? The video doesn't play? there's a traceback? Which error message? .... ?

If you define two primary fields the logic has a hard time to decide which is right. In fact it should fail, but doesn't.

Might it depend on the order of the behaviors?

Default File DX Type with enabled IRichtext Behavior, check it on https://demo-latest-plone6.plone.org/

Traceback (innermost last):
  Module ZPublisher.WSGIPublisher, line 167, in transaction_pubevents
  Module ZPublisher.WSGIPublisher, line 376, in publish_module
  Module ZPublisher.WSGIPublisher, line 271, in publish
  Module ZPublisher.mapply, line 85, in mapply
  Module ZPublisher.WSGIPublisher, line 68, in call_object
  Module plone.namedfile.browser, line 97, in __call__
  Module plone.namedfile.utils, line 140, in stream_data
AttributeError: 'RichTextValue' object has no attribute 'data'

This URL is ok: https://demo-latest-plone6.plone.org/de/file/view
This URL is broken: https://demo-latest-plone6.plone.org/de/file -> used in Toolbar on the View Button

plone.namedfile package tries resolve the primary field, this fails.

Thanks for hint!.

The file field is primary and the richtext field. Hmm... Who should wins?

Why not just add a rich text field instead of the behaviour ?

If I remember right, the rich text behavior is not searchable, so you have to add that anyway (?)

Ah, now I (and Jens) sees the problem, thanks! Yes indeed two primary fields is an issue.

The background here also are the content types that are in "use view fti for link actions" or whatever the list is called in the plone.registry.

For others: so by default if Plone has to generate a link to a contenttype there is a list where you can say: by default link to the create a nice '/view'. where you might see a preview and where you can download a file.

If you mainly have PDF’s as files in your site, you might want for example that links directly show your pdf insteaad of an intermidiate page.

I actually did a patch last week in a custom media file listing template I have created in a project. The site contains both pdf’s and mp4 video’s. These are both File CT. So I added the mime type which is in the metadata /brain anyway to a z3c.jbot overriden core listing template from which the other folder view templates inherit . And in my custom folder emplate that also inherits I differentiate between the links to add a /view only for video/* .

Somehow I think we should add this to core with a control panel extension to manage / map mime types instead .

Plone Foundation Code of Conduct