Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion CHANGES.rst
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@ Changelog
1.0b2 (unreleased)
------------------

- Nothing changed yet.
Bugfixes:
- Fix error with uploading file to theme editor. plone.rest no longer works in portal_resources. [displacedaussie]


1.0b1 (2017-05-14)
Expand Down
6 changes: 5 additions & 1 deletion src/plone/rest/testing.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
from plone.app.testing import PloneSandboxLayer
from plone.rest.service import Service
from plone.testing import z2

from zope.configuration import xmlconfig


Expand All @@ -14,6 +13,7 @@ class PloneRestLayer(PloneSandboxLayer):
defaultBases = (PLONE_APP_CONTENTTYPES_FIXTURE,)

def setUpZope(self, app, configurationContext):
z2.installProduct(app, 'plone.app.theming')
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@displacedaussie could you please elaborate why this is necessary here? I would like to keep the plone.rest test fixture as lightweight as possible.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Otherwise portal_resources doesn't exist. And that is what plone.rest is messing with the traversal of.

import plone.rest
xmlconfig.file(
'configure.zcml',
Expand All @@ -26,6 +26,10 @@ def setUpZope(self, app, configurationContext):
context=configurationContext
)

def setUpPloneSite(self, portal):
# Install into Plone site using portal_setup
self.applyProfile(portal, 'plone.app.theming:default')


PLONE_REST_FIXTURE = PloneRestLayer()
PLONE_REST_INTEGRATION_TESTING = IntegrationTesting(
Expand Down
4 changes: 4 additions & 0 deletions src/plone/rest/tests/test_traversal.py
Original file line number Diff line number Diff line change
Expand Up @@ -126,3 +126,7 @@ def test_json_request_to_view_namespace_returns_view(self):
self.portal[self.portal.invokeFactory('Folder', id='folder1')]
obj = self.traverse('/plone/folder1/@@folder_contents')
self.assertTrue(IBrowserView.providedBy(obj), 'IBrowserView expected')

def test_json_request_to_portal_resource_returns_page_template(self):
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@displacedaussie returning a page template on a JSON request violates the HTTP specs (content negotiation). If portal_resource is actually doing this should be fixed in Zope/Plone, not in plone.rest.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

obj = self.traverse('/plone/portal_resources')
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@displacedaussie this is not a POST request. Are you sure this test fails without the fix?

self.assertIsNotNone(obj, 'Object expected')
4 changes: 4 additions & 0 deletions src/plone/rest/traverse.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
from zope.interface import implements
from zope.publisher.interfaces.browser import IBrowserPublisher
from Products.CMFCore.interfaces import IContentish
from Products.BTreeFolder2.BTreeFolder2 import BTreeFolder2


class RESTTraverse(DefaultPublishTraverse):
Expand All @@ -21,6 +22,9 @@ def publishTraverse(self, request, name):
and not IService.providedBy(obj)):
if isinstance(obj, VirtualHostMonster):
return obj
elif (isinstance(obj, BTreeFolder2)
and obj.id == 'portal_resources'):
return obj
else:
raise KeyError
except KeyError:
Expand Down