Skip to content

plone.rest breaks theme file uploads #59

@displacedaussie

Description

@displacedaussie

Problem

In the Plone theme editor it's possible to upload files.

Via the upload pattern, this ends up attempting to POST the file to something like:

http://localhost:8080/Plone/portal_resources/theme/test-theme/themeFileUpload

However this request gets flagged as an IAPIRequest by plone.rest and is therefore handled by RESTTraverse:

https://github.com/plone/plone.rest/blob/master/src/plone/rest/traverse.py#L17

(Pdb) self
<plone.rest.traverse.RESTTraverse object at 0x113613810>
(Pdb) request
<HTTPRequest, URL=http://localhost:8080/Plone/portal_resources>
(Pdb) name
'portal_resources'

During traversal it gets the portal_resources object, but this isn't IContentish or an IService and so it raises a KeyError rather than returning the object.

(Pdb) obj
<BTreeFolder2 at /Plone/portal_resources>
(Pdb) IContentish.providedBy(obj)
False
(Pdb) IService.providedBy(obj)
False

https://github.com/plone/plone.rest/blob/master/src/plone/rest/traverse.py#L25

When handling the Exception, there are no valid view lookups so it raises the Error. This then results in a 404 to the themeFileUpload URL and a "File transfer failed" in the theme file upload UI.

Options

  • Check for more than IContentish and IService during traversal so that objects like this are returned correctly?
  • Don't flag this request as an IAPIRequest so it's handled by normal traversal?
  • Configure something elsewhere (in plone.resource?) so that traversal works as expected?

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions