plone.restapi/plone-only-login: Move all expandable elements into '@components' attribute
Thomas Buchberger <jenkins-z4DKO/[email protected]> Wed, 26 Jul 2017 07:45:53 -0700 (PDT)
| Newsgroups | gmane.comp.web.zope.plone.cvs |
|---|---|
| Message-ID | <[email protected]> |
Repository: plone.restapi Branch: refs/heads/plone-only-login Date: 2017-07-25T14:05:38+02:00 Author: Thomas Buchberger (buchi) <t.buchberger-/8aE7x569Db/[email protected]> Commit: https://github.com/plone/plone.restapi/commit/7e8cdd17a6d39610f0a9d394f30378412f7c912a Move all expandable elements into '@components' attribute Files changed: M docs/source/_json/collection.resp M docs/source/_json/content_get.resp M docs/source/_json/content_post.resp M docs/source/_json/document.resp M docs/source/_json/event.resp M docs/source/_json/expansion.resp M docs/source/_json/expansion_expanded.resp M docs/source/_json/expansion_expanded_full.resp M docs/source/_json/file.resp M docs/source/_json/folder.resp M docs/source/_json/image.resp M docs/source/_json/jwt_logged_in.resp M docs/source/_json/link.resp M docs/source/_json/newsitem.resp M docs/source/_json/siteroot.resp M src/plone/restapi/serializer/expansion.py M src/plone/restapi/tests/test_atcontent_serializer.py M src/plone/restapi/tests/test_components.py M src/plone/restapi/tests/test_dxcontent_serializer.py M src/plone/restapi/tests/test_expansion.py M src/plone/restapi/tests/test_workflow.py diff --git a/docs/source/_json/collection.resp b/docs/source/_json/collection.resp index 7640e732..4927c64d 100644 --- a/docs/source/_json/collection.resp +++ b/docs/source/_json/collection.resp @@ -3,18 +3,20 @@ Content-Type: application/json { "@components": { - "breadcrumbs": { - "@id": "http://localhost:55001/plone/collection/@components/breadcrumbs" + "@components": { + "breadcrumbs": { + "@id": "http://localhost:55001/plone/collection/@components/breadcrumbs" + }, + "navigation": { + "@id": "http://localhost:55001/plone/collection/@components/navigation" + } }, - "navigation": { - "@id": "http://localhost:55001/plone/collection/@components/navigation" + "@workflow": { + "@id": "http://localhost:55001/plone/collection/@workflow" } }, "@id": "http://localhost:55001/plone/collection", "@type": "Collection", - "@workflow": { - "@id": "http://localhost:55001/plone/collection/@workflow" - }, "UID": "SomeUUID000000000000000000000002", "allow_discussion": null, "contributors": [], diff --git a/docs/source/_json/content_get.resp b/docs/source/_json/content_get.resp index 2a7b48ee..a13516ef 100644 --- a/docs/source/_json/content_get.resp +++ b/docs/source/_json/content_get.resp @@ -3,18 +3,20 @@ Content-Type: application/json { "@components": { - "breadcrumbs": { - "@id": "http://localhost:55001/plone/folder/my-document/@components/breadcrumbs" + "@components": { + "breadcrumbs": { + "@id": "http://localhost:55001/plone/folder/my-document/@components/breadcrumbs" + }, + "navigation": { + "@id": "http://localhost:55001/plone/folder/my-document/@components/navigation" + } }, - "navigation": { - "@id": "http://localhost:55001/plone/folder/my-document/@components/navigation" + "@workflow": { + "@id": "http://localhost:55001/plone/folder/my-document/@workflow" } }, "@id": "http://localhost:55001/plone/folder/my-document", "@type": "Document", - "@workflow": { - "@id": "http://localhost:55001/plone/folder/my-document/@workflow" - }, "UID": "SomeUUID000000000000000000000005", "allow_discussion": null, "changeNote": "", diff --git a/docs/source/_json/content_post.resp b/docs/source/_json/content_post.resp index 36da1d20..5e3acd2c 100644 --- a/docs/source/_json/content_post.resp +++ b/docs/source/_json/content_post.resp @@ -4,18 +4,20 @@ Location: http://localhost:55001/plone/folder/my-document { "@components": { - "breadcrumbs": { - "@id": "http://localhost:55001/plone/folder/my-document/@components/breadcrumbs" + "@components": { + "breadcrumbs": { + "@id": "http://localhost:55001/plone/folder/my-document/@components/breadcrumbs" + }, + "navigation": { + "@id": "http://localhost:55001/plone/folder/my-document/@components/navigation" + } }, - "navigation": { - "@id": "http://localhost:55001/plone/folder/my-document/@components/navigation" + "@workflow": { + "@id": "http://localhost:55001/plone/folder/my-document/@workflow" } }, "@id": "http://localhost:55001/plone/folder/my-document", "@type": "Document", - "@workflow": { - "@id": "http://localhost:55001/plone/folder/my-document/@workflow" - }, "UID": "SomeUUID000000000000000000000005", "allow_discussion": null, "changeNote": "", diff --git a/docs/source/_json/document.resp b/docs/source/_json/document.resp index e3aadc15..d9b64694 100644 --- a/docs/source/_json/document.resp +++ b/docs/source/_json/document.resp @@ -3,18 +3,20 @@ Content-Type: application/json { "@components": { - "breadcrumbs": { - "@id": "http://localhost:55001/plone/front-page/@components/breadcrumbs" + "@components": { + "breadcrumbs": { + "@id": "http://localhost:55001/plone/front-page/@components/breadcrumbs" + }, + "navigation": { + "@id": "http://localhost:55001/plone/front-page/@components/navigation" + } }, - "navigation": { - "@id": "http://localhost:55001/plone/front-page/@components/navigation" + "@workflow": { + "@id": "http://localhost:55001/plone/front-page/@workflow" } }, "@id": "http://localhost:55001/plone/front-page", "@type": "Document", - "@workflow": { - "@id": "http://localhost:55001/plone/front-page/@workflow" - }, "UID": "SomeUUID000000000000000000000001", "allow_discussion": null, "changeNote": "", diff --git a/docs/source/_json/event.resp b/docs/source/_json/event.resp index 974db379..42e2d492 100644 --- a/docs/source/_json/event.resp +++ b/docs/source/_json/event.resp @@ -3,18 +3,20 @@ Content-Type: application/json { "@components": { - "breadcrumbs": { - "@id": "http://localhost:55001/plone/event/@components/breadcrumbs" + "@components": { + "breadcrumbs": { + "@id": "http://localhost:55001/plone/event/@components/breadcrumbs" + }, + "navigation": { + "@id": "http://localhost:55001/plone/event/@components/navigation" + } }, - "navigation": { - "@id": "http://localhost:55001/plone/event/@components/navigation" + "@workflow": { + "@id": "http://localhost:55001/plone/event/@workflow" } }, "@id": "http://localhost:55001/plone/event", "@type": "Event", - "@workflow": { - "@id": "http://localhost:55001/plone/event/@workflow" - }, "UID": "SomeUUID000000000000000000000002", "allow_discussion": null, "attendees": [], diff --git a/docs/source/_json/expansion.resp b/docs/source/_json/expansion.resp index e3aadc15..d9b64694 100644 --- a/docs/source/_json/expansion.resp +++ b/docs/source/_json/expansion.resp @@ -3,18 +3,20 @@ Content-Type: application/json { "@components": { - "breadcrumbs": { - "@id": "http://localhost:55001/plone/front-page/@components/breadcrumbs" + "@components": { + "breadcrumbs": { + "@id": "http://localhost:55001/plone/front-page/@components/breadcrumbs" + }, + "navigation": { + "@id": "http://localhost:55001/plone/front-page/@components/navigation" + } }, - "navigation": { - "@id": "http://localhost:55001/plone/front-page/@components/navigation" + "@workflow": { + "@id": "http://localhost:55001/plone/front-page/@workflow" } }, "@id": "http://localhost:55001/plone/front-page", "@type": "Document", - "@workflow": { - "@id": "http://localhost:55001/plone/front-page/@workflow" - }, "UID": "SomeUUID000000000000000000000001", "allow_discussion": null, "changeNote": "", diff --git a/docs/source/_json/expansion_expanded.resp b/docs/source/_json/expansion_expanded.resp index afe45d4b..5a9b1f25 100644 --- a/docs/source/_json/expansion_expanded.resp +++ b/docs/source/_json/expansion_expanded.resp @@ -3,21 +3,23 @@ Content-Type: application/json { "@components": { - "breadcrumbs": [ - { - "title": "Welcome to Plone", - "url": "http://localhost:55001/plone/front-page" + "@components": { + "breadcrumbs": [ + { + "title": "Welcome to Plone", + "url": "http://localhost:55001/plone/front-page" + } + ], + "navigation": { + "@id": "http://localhost:55001/plone/front-page/@components/navigation" } - ], - "navigation": { - "@id": "http://localhost:55001/plone/front-page/@components/navigation" + }, + "@workflow": { + "@id": "http://localhost:55001/plone/front-page/@workflow" } }, "@id": "http://localhost:55001/plone/front-page", "@type": "Document", - "@workflow": { - "@id": "http://localhost:55001/plone/front-page/@workflow" - }, "UID": "SomeUUID000000000000000000000001", "allow_discussion": null, "changeNote": "", diff --git a/docs/source/_json/expansion_expanded_full.resp b/docs/source/_json/expansion_expanded_full.resp index eafc9360..7456da91 100644 --- a/docs/source/_json/expansion_expanded_full.resp +++ b/docs/source/_json/expansion_expanded_full.resp @@ -3,47 +3,49 @@ Content-Type: application/json { "@components": { - "breadcrumbs": [ - { - "title": "Welcome to Plone", - "url": "http://localhost:55001/plone/front-page" - } - ], - "navigation": [ - { - "title": "Home", - "url": "http://localhost:55001/plone" - }, - { - "title": "Welcome to Plone", - "url": "http://localhost:55001/plone/front-page" - } - ] + "@components": { + "breadcrumbs": [ + { + "title": "Welcome to Plone", + "url": "http://localhost:55001/plone/front-page" + } + ], + "navigation": [ + { + "title": "Home", + "url": "http://localhost:55001/plone" + }, + { + "title": "Welcome to Plone", + "url": "http://localhost:55001/plone/front-page" + } + ] + }, + "@workflow": { + "history": [ + { + "action": null, + "actor": "test_user_1_", + "comments": "", + "review_state": "private", + "time": "2016-10-21T19:00:00+00:00", + "title": "Private" + } + ], + "transitions": [ + { + "@id": "http://localhost:55001/plone/front-page/@workflow/publish", + "title": "Publish" + }, + { + "@id": "http://localhost:55001/plone/front-page/@workflow/submit", + "title": "Submit for publication" + } + ] + } }, "@id": "http://localhost:55001/plone/front-page", "@type": "Document", - "@workflow": { - "history": [ - { - "action": null, - "actor": "test_user_1_", - "comments": "", - "review_state": "private", - "time": "2016-10-21T19:00:00+00:00", - "title": "Private" - } - ], - "transitions": [ - { - "@id": "http://localhost:55001/plone/front-page/@workflow/publish", - "title": "Publish" - }, - { - "@id": "http://localhost:55001/plone/front-page/@workflow/submit", - "title": "Submit for publication" - } - ] - }, "UID": "SomeUUID000000000000000000000001", "allow_discussion": null, "changeNote": "", diff --git a/docs/source/_json/file.resp b/docs/source/_json/file.resp index 515cfeb8..c1374a34 100644 --- a/docs/source/_json/file.resp +++ b/docs/source/_json/file.resp @@ -3,18 +3,20 @@ Content-Type: application/json { "@components": { - "breadcrumbs": { - "@id": "http://localhost:55001/plone/file/@components/breadcrumbs" + "@components": { + "breadcrumbs": { + "@id": "http://localhost:55001/plone/file/@components/breadcrumbs" + }, + "navigation": { + "@id": "http://localhost:55001/plone/file/@components/navigation" + } }, - "navigation": { - "@id": "http://localhost:55001/plone/file/@components/navigation" + "@workflow": { + "@id": "http://localhost:55001/plone/file/@workflow" } }, "@id": "http://localhost:55001/plone/file", "@type": "File", - "@workflow": { - "@id": "http://localhost:55001/plone/file/@workflow" - }, "UID": "SomeUUID000000000000000000000002", "allow_discussion": null, "contributors": [], diff --git a/docs/source/_json/folder.resp b/docs/source/_json/folder.resp index 4a12e3eb..e711350f 100644 --- a/docs/source/_json/folder.resp +++ b/docs/source/_json/folder.resp @@ -3,18 +3,20 @@ Content-Type: application/json { "@components": { - "breadcrumbs": { - "@id": "http://localhost:55001/plone/folder/@components/breadcrumbs" + "@components": { + "breadcrumbs": { + "@id": "http://localhost:55001/plone/folder/@components/breadcrumbs" + }, + "navigation": { + "@id": "http://localhost:55001/plone/folder/@components/navigation" + } }, - "navigation": { - "@id": "http://localhost:55001/plone/folder/@components/navigation" + "@workflow": { + "@id": "http://localhost:55001/plone/folder/@workflow" } }, "@id": "http://localhost:55001/plone/folder", "@type": "Folder", - "@workflow": { - "@id": "http://localhost:55001/plone/folder/@workflow" - }, "UID": "SomeUUID000000000000000000000002", "allow_discussion": null, "contributors": [], diff --git a/docs/source/_json/image.resp b/docs/source/_json/image.resp index df1bd765..b7396435 100644 --- a/docs/source/_json/image.resp +++ b/docs/source/_json/image.resp @@ -3,18 +3,20 @@ Content-Type: application/json { "@components": { - "breadcrumbs": { - "@id": "http://localhost:55001/plone/image/@components/breadcrumbs" + "@components": { + "breadcrumbs": { + "@id": "http://localhost:55001/plone/image/@components/breadcrumbs" + }, + "navigation": { + "@id": "http://localhost:55001/plone/image/@components/navigation" + } }, - "navigation": { - "@id": "http://localhost:55001/plone/image/@components/navigation" + "@workflow": { + "@id": "http://localhost:55001/plone/image/@workflow" } }, "@id": "http://localhost:55001/plone/image", "@type": "Image", - "@workflow": { - "@id": "http://localhost:55001/plone/image/@workflow" - }, "UID": "SomeUUID000000000000000000000002", "allow_discussion": null, "contributors": [], diff --git a/docs/source/_json/jwt_logged_in.resp b/docs/source/_json/jwt_logged_in.resp index d9a441ca..8630e5fa 100644 --- a/docs/source/_json/jwt_logged_in.resp +++ b/docs/source/_json/jwt_logged_in.resp @@ -3,11 +3,13 @@ Content-Type: application/json { "@components": { - "breadcrumbs": { - "@id": "http://localhost:55001/plone/@components/breadcrumbs" - }, - "navigation": { - "@id": "http://localhost:55001/plone/@components/navigation" + "@components": { + "breadcrumbs": { + "@id": "http://localhost:55001/plone/@components/breadcrumbs" + }, + "navigation": { + "@id": "http://localhost:55001/plone/@components/navigation" + } } }, "@id": "http://localhost:55001/plone/", diff --git a/docs/source/_json/link.resp b/docs/source/_json/link.resp index 6eba0e69..66aa8179 100644 --- a/docs/source/_json/link.resp +++ b/docs/source/_json/link.resp @@ -3,18 +3,20 @@ Content-Type: application/json { "@components": { - "breadcrumbs": { - "@id": "http://localhost:55001/plone/link/@components/breadcrumbs" + "@components": { + "breadcrumbs": { + "@id": "http://localhost:55001/plone/link/@components/breadcrumbs" + }, + "navigation": { + "@id": "http://localhost:55001/plone/link/@components/navigation" + } }, - "navigation": { - "@id": "http://localhost:55001/plone/link/@components/navigation" + "@workflow": { + "@id": "http://localhost:55001/plone/link/@workflow" } }, "@id": "http://localhost:55001/plone/link", "@type": "Link", - "@workflow": { - "@id": "http://localhost:55001/plone/link/@workflow" - }, "UID": "SomeUUID000000000000000000000002", "allow_discussion": null, "changeNote": "", diff --git a/docs/source/_json/newsitem.resp b/docs/source/_json/newsitem.resp index ae9f6d09..17f89f37 100644 --- a/docs/source/_json/newsitem.resp +++ b/docs/source/_json/newsitem.resp @@ -3,18 +3,20 @@ Content-Type: application/json { "@components": { - "breadcrumbs": { - "@id": "http://localhost:55001/plone/newsitem/@components/breadcrumbs" + "@components": { + "breadcrumbs": { + "@id": "http://localhost:55001/plone/newsitem/@components/breadcrumbs" + }, + "navigation": { + "@id": "http://localhost:55001/plone/newsitem/@components/navigation" + } }, - "navigation": { - "@id": "http://localhost:55001/plone/newsitem/@components/navigation" + "@workflow": { + "@id": "http://localhost:55001/plone/newsitem/@workflow" } }, "@id": "http://localhost:55001/plone/newsitem", "@type": "News Item", - "@workflow": { - "@id": "http://localhost:55001/plone/newsitem/@workflow" - }, "UID": "SomeUUID000000000000000000000002", "allow_discussion": null, "changeNote": "", diff --git a/docs/source/_json/siteroot.resp b/docs/source/_json/siteroot.resp index 30894897..b21bc3d4 100644 --- a/docs/source/_json/siteroot.resp +++ b/docs/source/_json/siteroot.resp @@ -3,11 +3,13 @@ Content-Type: application/json { "@components": { - "breadcrumbs": { - "@id": "http://localhost:55001/plone/@components/breadcrumbs" - }, - "navigation": { - "@id": "http://localhost:55001/plone/@components/navigation" + "@components": { + "breadcrumbs": { + "@id": "http://localhost:55001/plone/@components/breadcrumbs" + }, + "navigation": { + "@id": "http://localhost:55001/plone/@components/navigation" + } } }, "@id": "http://localhost:55001/plone", diff --git a/src/plone/restapi/serializer/expansion.py b/src/plone/restapi/serializer/expansion.py index 825d34ba..cdf0eec8 100644 --- a/src/plone/restapi/serializer/expansion.py +++ b/src/plone/restapi/serializer/expansion.py @@ -14,7 +14,7 @@ def expandable_elements(context, request): update_dict_recursively(res, element[1](expand=True)) else: update_dict_recursively(res, element[1](expand=False)) - return res + return {"@components": res} def update_dict_recursively(d, u): diff --git a/src/plone/restapi/tests/test_atcontent_serializer.py b/src/plone/restapi/tests/test_atcontent_serializer.py index 09d41f87..ac4c1fad 100644 --- a/src/plone/restapi/tests/test_atcontent_serializer.py +++ b/src/plone/restapi/tests/test_atcontent_serializer.py @@ -163,5 +163,5 @@ def test_serializer_includes_expansion(self): name='foo' ) obj = self.serialize(self.doc1) - self.assertIn('foo', obj) - self.assertEqual('collapsed', obj['foo']) + self.assertIn('foo', obj['@components']) + self.assertEqual('collapsed', obj['@components']['foo']) diff --git a/src/plone/restapi/tests/test_components.py b/src/plone/restapi/tests/test_components.py index 1c7e232b..18d17c61 100644 --- a/src/plone/restapi/tests/test_components.py +++ b/src/plone/restapi/tests/test_components.py @@ -57,13 +57,13 @@ def test_breadcrumb(self): def test_collapsed_breadcrumbs_in_content_serialization(self): obj = self.api_session.get('/folder').json() self.assertIn('@components', obj) - self.assertIn('breadcrumbs', obj['@components']) - self.assertIn('@id', obj['@components']['breadcrumbs']) + self.assertIn('breadcrumbs', obj['@components']['@components']) + self.assertIn('@id', obj['@components']['@components']['breadcrumbs']) def test_expanded_breadcrumbs_in_content_serialization(self): obj = self.api_session.get('/folder/doc1?expand=breadcrumbs').json() self.assertIn('@components', obj) - self.assertIn('breadcrumbs', obj['@components']) + self.assertIn('breadcrumbs', obj['@components']['@components']) self.assertEqual( [{ u'url': u'http://localhost:55001/plone/folder', @@ -72,7 +72,7 @@ def test_expanded_breadcrumbs_in_content_serialization(self): u'url': u'http://localhost:55001/plone/folder/doc1', u'title': u'A document' }], - obj['@components']['breadcrumbs']) + obj['@components']['@components']['breadcrumbs']) def test_navigation(self): response = self.api_session.get('/folder/@components/navigation') @@ -96,13 +96,13 @@ def test_navigation(self): def test_collapsed_navigation_in_content_serialization(self): obj = self.api_session.get('/folder').json() self.assertIn('@components', obj) - self.assertIn('navigation', obj['@components']) - self.assertIn('@id', obj['@components']['navigation']) + self.assertIn('navigation', obj['@components']['@components']) + self.assertIn('@id', obj['@components']['@components']['navigation']) def test_expanded_navigation_in_content_serialization(self): obj = self.api_session.get('/folder?expand=navigation').json() self.assertIn('@components', obj) - self.assertIn('navigation', obj['@components']) + self.assertIn('navigation', obj['@components']['@components']) self.assertEqual( [{ u'title': u'Home', @@ -111,4 +111,4 @@ def test_expanded_navigation_in_content_serialization(self): u'title': u'Some Folder', u'url': u'http://localhost:55001/plone/folder' }], - obj['@components']['navigation']) + obj['@components']['@components']['navigation']) diff --git a/src/plone/restapi/tests/test_dxcontent_serializer.py b/src/plone/restapi/tests/test_dxcontent_serializer.py index 80c3ac01..f9ad1c8f 100644 --- a/src/plone/restapi/tests/test_dxcontent_serializer.py +++ b/src/plone/restapi/tests/test_dxcontent_serializer.py @@ -136,5 +136,5 @@ def test_serializer_includes_expansion(self): name='foo' ) obj = self.serialize() - self.assertIn('foo', obj) - self.assertEqual('collapsed', obj['foo']) + self.assertIn('foo', obj['@components']) + self.assertEqual('collapsed', obj['@components']['foo']) diff --git a/src/plone/restapi/tests/test_expansion.py b/src/plone/restapi/tests/test_expansion.py index 394c3f8b..51193401 100644 --- a/src/plone/restapi/tests/test_expansion.py +++ b/src/plone/restapi/tests/test_expansion.py @@ -53,15 +53,18 @@ def setUp(self): def test_expansion_returns_collapsed_elements(self): request = TestRequest() - self.assertEqual({'foo': 'collapsed', 'bar': 'collapsed'}, - expandable_elements(None, request)) + self.assertEqual( + {'@components': {'bar': 'collapsed', 'foo': 'collapsed'}}, + expandable_elements(None, request)) def test_expansion_returns_expanded_element(self): request = TestRequest(form={'expand': 'foo'}) - self.assertEqual({'foo': 'expanded', 'bar': 'collapsed'}, - expandable_elements(None, request)) + self.assertEqual( + {'@components': {'bar': 'collapsed', 'foo': 'expanded'}}, + expandable_elements(None, request)) def test_expansion_returns_multiple_expanded_elements(self): request = TestRequest(form={'expand': 'foo,bar'}) - self.assertEqual({'foo': 'expanded', 'bar': 'expanded'}, - expandable_elements(None, request)) + self.assertEqual( + {'@components': {'bar': 'expanded', 'foo': 'expanded'}}, + expandable_elements(None, request)) diff --git a/src/plone/restapi/tests/test_workflow.py b/src/plone/restapi/tests/test_workflow.py index 5df39224..0c9f6a5e 100644 --- a/src/plone/restapi/tests/test_workflow.py +++ b/src/plone/restapi/tests/test_workflow.py @@ -48,17 +48,17 @@ def test_collapsed_workflow_info_in_content_serialization(self): serializer = getMultiAdapter((self.doc1, self.request), ISerializeToJson) obj = serializer() - self.assertIn('@workflow', obj) - self.assertIn('@id', obj['@workflow']) + self.assertIn('@workflow', obj['@components']) + self.assertIn('@id', obj['@components']['@workflow']) def test_expanded_workflow_info_in_content_serialization(self): self.request.form.update({'expand': 'workflow'}) serializer = getMultiAdapter((self.doc1, self.request), ISerializeToJson) obj = serializer() - self.assertIn('@workflow', obj) - self.assertIn('transitions', obj['@workflow']) - self.assertIn('history', obj['@workflow']) + self.assertIn('@workflow', obj['@components']) + self.assertIn('transitions', obj['@components']['@workflow']) + self.assertIn('history', obj['@components']['@workflow']) class TestWorkflowTransition(TestCase): ------------------------------------------------------------------------------ Check out the vibrant tech community on one of the world's most engaging tech sites, Slashdot.org! http://sdm.link/slashdot