Plone 5.1rc2 Image upload in tinymce in static portlet richtext area fails with 404

I can reproduce in a standard plone 5.1rc2 with no additional modules.

In the browser:
Failed to load resource: the server responded with a status of 404 (Not Found) http://localhost:8089/site/front-page/++contextportlets++plone.rightcolumn/@@fileUpload

clearly either the portlet context for the @@fileUpload view is wrong, or the view needs to be registered more broadly.

Not sure if this is a know issue? If not, I will file a bug report - where do I do this, in the github issue tracker for plone/Products.CMFPlone ?

I can work on a fix if I get some guidance to what the best solution is - is this a general problem in the portlet rich text field context, or should it be handled in the @@fileUpload view?
My guess is this also affects other cases where a tinymce widget is used on non-content objects (mosaic? not sure about the architecture here).

Yes please!

submitted: https://github.com/plone/Products.CMFPlone/issues/2283

1 Like

I did update the GithHub issue to note that I could reproduce it.

In the meantime, here is a workaround that I just implemented for a project. It overrides the fileUpload view to make it available to all interfaces, and adds a custom __init__ to make sure we get a folderish item.

configure.zcml:

  <configure package="plone.app.content.browser">
      <browser:page
          name="fileUpload"
          for="*"
          class="my.package.file.FileUploadViewFix"
          permission="zope2.View"
          layer="intranet.cleantheme.interfaces.ICustomTheme"
          />
  </configure>

file.py:

from OFS.interfaces import IFolder
from plone.app.content.browser.file import FileUploadView


class FileUploadViewFix(FileUploadView):
    """FileUploadView available for all interfaces.
       If context is not folderish, get the parent
    """

    def __init__(self, context, request):
        if IFolder.providedBy(context):
            self.context = context
        else:
            for loc in context.aq_chain:
                if IFolder.providedBy(loc):
                    self.context = loc
                    break
        self.request = request
1 Like