Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

plone.restapi breaks Plone 5.0.4 File bulk uploads #74

Closed
mjmare opened this issue Apr 15, 2016 · 5 comments
Closed

plone.restapi breaks Plone 5.0.4 File bulk uploads #74

mjmare opened this issue Apr 15, 2016 · 5 comments

Comments

@mjmare
Copy link

mjmare commented Apr 15, 2016

Having Plone.restapi (plone.restapi 0.1, plone.rest = 1.0a5) installed breaks the file upload functionality in a stock Plone 5 (at least in versions 5.0.3/4). Dragging files into the upload area and pressing upload yields the text "The file upload failed" just below the filename and nothing happens.

my_docs_ _site

I have installed plone restapi with:
`auto-checkout = plone.restapi

eggs =
Plone
Pillow
plone.restapi

[sources]
plone.restapi = git https://github.com/plone/plone.restapi
`
and running buildout -c develop.cfg.

Disabling the restapi egg restores file uploads.

The Plone error log show two errors (after clearing "Ignored exception types"):

`Traceback (innermost last):
Module ZPublisher.Publish, line 127, in publish
Module ZPublisher.BaseRequest, line 523, in traverse
Module ZPublisher.HTTPResponse, line 727, in debugError
NotFound:

Site Error

An error was encountered while publishing this resource.

Debugging Notice

Zope has encountered a problem publishing your object.


Cannot locate object at: http://localhost:8080/testing/my-docs/fileUpload


Troubleshooting Suggestions

  • The URL may be incorrect.
  • The parameters passed to this resource may be incorrect.
  • A resource that this resource relies on may be encountering an error.

For more detailed information about the error, please refer to the error log.

If the error persists please contact the site maintainer. Thank you for your patience.

`

and:

Traceback (innermost last): Module ZPublisher.Publish, line 127, in publish Module ZPublisher.BaseRequest, line 508, in traverse Module ZPublisher.BaseRequest, line 332, in traverseName Module zope.traversing.namespace, line 112, in namespaceLookup Module Products.CMFPlone.traversal, line 39, in traverse Module plone.resource.traversal, line 27, in traverse NotFound

@tisto
Copy link
Member

tisto commented Apr 18, 2016

@mjmare thanks for the detailed bug report. we will look into it!

@mjmare
Copy link
Author

mjmare commented Apr 18, 2016

You're welcome!

@lukasgraf
Copy link
Member

This issue most likely originates in plone.rest.

The failing request is made to the fileUpload browser view with Accept: application/json.

If a request with an Accept header other than text/html is handled, mark_as_api_request() flags the request with IAPIRequest as soon as at least one service registered for that content-type and HTTP method exists in the service registry.

This will then cause a KeyError to be raised in plone.rest.traverse because the conditions don't match. => 404

Failing test (for plone.rest):

#class TestTraversal(unittest.TestCase):

    def test_json_request_to_regular_view_still_possible(self):
        obj = self.traverse('/plone/some-view')
        self.assertEquals(obj(), '{"msg": "Hello from SomeView"}')
from Products.Five.browser import BrowserView
import json

class SomeView(BrowserView):
    def __call__(self):
        return json.dumps({'msg': 'Hello from SomeView'})
  <browser:page
    name="some-view"
    for="*"
    class=".tests.view.SomeView"
    permission="zope2.View"
    />

/cc @buchi

@tisto
Copy link
Member

tisto commented May 16, 2016

This is actually a plone.rest issue. Moved it there: plone/plone.rest#50

@tisto tisto closed this as completed May 16, 2016
@lukasgraf
Copy link
Member

@mjmare fixed in current master of plone.rest (see plone/plone.rest#53).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants