Skip to content

Commit

Permalink
Merge branch 'master' into respect-types-not-searched
Browse files Browse the repository at this point in the history
  • Loading branch information
rodfersou committed Apr 9, 2020
2 parents 774a4b0 + 864d566 commit 39fc48d
Show file tree
Hide file tree
Showing 55 changed files with 1,221 additions and 38 deletions.
42 changes: 41 additions & 1 deletion CHANGES.rst
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,47 @@ Changelog
.. towncrier release notes start
- Respect `types_not_searched` field for search [rodfersou] (#861)
6.6.0 (2020-04-07)
------------------

New features:


- Add next_item and previous_item attributes to allow to navigate to the previous and next sibling in the container the document is located.
[rodfersou] (#900)


6.5.2 (2020-04-01)
------------------

Bug fixes:


- Fix for the use case while updating user properties in the @user endpoint, and the
portrait is already previously set but the request includes the (previously) serialized
value as a string because the user are not updating it
[sneridagh] (#896)


6.5.1 (2020-04-01)
------------------

Bug fixes:


- Fix deleting user portrait.
[buchi] (#751)


6.5.0 (2020-03-30)
------------------

New features:


- Link translation on content creation feature and new @translation-locator endpoint
[sneridagh] (#887)


6.4.1 (2020-03-25)
------------------
Expand Down
Binary file added Data.fs
Binary file not shown.
2 changes: 1 addition & 1 deletion Jenkinsfile
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ pipeline {
}

options {
buildDiscarder(logRotator(numToKeepStr:'30'))
buildDiscarder(logRotator(numToKeepStr:'100'))
timeout(time: 30, unit: 'MINUTES')
disableConcurrentBuilds()
}
Expand Down
23 changes: 23 additions & 0 deletions docs/source/conventions.rst
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,29 @@ Discussion:
https://github.com/plone/plone.restapi/issues/194


Naming Convention for attribute names in response body
------------------------------------------------------

Rule: Use snake_case to reflect Python best practices.

Do::

{
translation_of: ...
}

Don't::

{
translationOf: ...,
TranslationOf: ...,
}

Reason:

We map over Python attributes 1:1 no matter if they are snake case (modern Python/Plone, Dexterity) of lowerCamelCase (Zope 2, Archetypes).


Versioning
----------

Expand Down
53 changes: 53 additions & 0 deletions docs/source/serialization.rst
Original file line number Diff line number Diff line change
Expand Up @@ -193,3 +193,56 @@ Specify relations by intid:
"relatedItems": [347127075, 347127076]
}
Next/Previous/Parent Navigation
-------------------------------

The response body of a GET request contains three attributes that allows navigating to the parent and the next and previous sibling in the container the current document is located.

Parent
^^^^^^

The "parent" attribute points to the parent container of the current content object.

.. code-block:: json
{
"parent": {
"@id": "http://nohost/plone/folder-with-items",
"@type": "Folder",
"title": "Folder with items",
"description": "This is a folder with two documents",
}
}
Previous Item
^^^^^^^^^^^^^

The "previous_item" attribute points to the sibling that is located before the current element in the parent container (Plone uses the getObjectPositionInParent attribute to sort content objects within a folderish container).

.. code-block:: json
{
"previous_item": {
"@id": "http://nohost/plone/folder-with-items/item-1",
"@type": "Document",
"title": "Item 1",
"description": "This the previous item"
}
}
Next Item
^^^^^^^^^

The "next_item" attribute points to the sibling that is located after the current element in the parent container (Plone uses the getObjectPositionInParent attribute to sort content objects within a folderish container).

.. code-block:: json
{
"next_item": {
"@id": "http://nohost/plone/folder-with-items/item-2",
"@type": "Document",
"title": "Item 2",
"description": "This the next item"
}
}
26 changes: 25 additions & 1 deletion docs/source/translations.rst
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,30 @@ endpoint of the content item and provide the language code you want to unlink.:
.. literalinclude:: ../../src/plone/restapi/tests/http-examples/translations_delete.resp
:language: http

Creating a translation from an existing content
-----------------------------------------------

The POST content endpoint to a folder is capable also of linking this new content with an
exising translation using two parameters: ``translationOf`` and ``language``.

.. http:example:: curl httpie python-requests
:request: ../../src/plone/restapi/tests/http-examples/translations_link_on_post.req

.. literalinclude:: ../../src/plone/restapi/tests/http-examples/translations_link_on_post.resp
:language: http

Get location in the tree for new translations
---------------------------------------------

When you create a translation in Plone, there are policies in place for finding a suitable
placement for it. This endpoint returns the proper placement for the newly going to be
created translation.

.. http:example:: curl httpie python-requests
:request: ../../src/plone/restapi/tests/http-examples/translation_locator.req

.. literalinclude:: ../../src/plone/restapi/tests/http-examples/translation_locator.resp
:language: http

Expansion
---------
Expand All @@ -98,4 +122,4 @@ entry with the URL of the `@translations` endpoint:

.. _`plone.app.multilingual`: https://pypi.python.org/pypi/plone.app.multilingual
.. _`Products.LinguaPlone`: https://pypi.python.org/pypi/Products.LinguaPlone.
.. _`documentation`: https://docs.plone.org/develop/plone/i18n/translating_content.html
.. _`documentation`: https://docs.plone.org/develop/plone/i18n/translating_content.html
2 changes: 2 additions & 0 deletions news/861.feature
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
Respect `types_not_searched` field for search
[rodfersou] (#861)
56 changes: 55 additions & 1 deletion performance.jmx
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
<stringProp name="TestPlan.user_define_classpath"></stringProp>
</TestPlan>
<hashTree>
<ThreadGroup guiclass="ThreadGroupGui" testclass="ThreadGroup" testname="Authenticated Users (Create)" enabled="true">
<ThreadGroup guiclass="ThreadGroupGui" testclass="ThreadGroup" testname="Authenticated Users (Write)" enabled="true">
<stringProp name="ThreadGroup.on_sample_error">continue</stringProp>
<elementProp name="ThreadGroup.main_controller" elementType="LoopController" guiclass="LoopControlPanel" testclass="LoopController" testname="Loop Controller" enabled="true">
<boolProp name="LoopController.continue_forever">false</boolProp>
Expand Down Expand Up @@ -491,6 +491,33 @@
<stringProp name="HTTPSampler.response_timeout"></stringProp>
</HTTPSamplerProxy>
<hashTree/>
<HTTPSamplerProxy guiclass="HttpTestSampleGui" testclass="HTTPSamplerProxy" testname="Document (next/prev)" enabled="true">
<elementProp name="HTTPsampler.Arguments" elementType="Arguments" guiclass="HTTPArgumentsPanel" testclass="Arguments" testname="Benutzer definierte Variablen" enabled="true">
<collectionProp name="Arguments.arguments">
<elementProp name="Accept" elementType="HTTPArgument">
<boolProp name="HTTPArgument.always_encode">false</boolProp>
<stringProp name="Argument.value">application/json</stringProp>
<stringProp name="Argument.metadata">=</stringProp>
<boolProp name="HTTPArgument.use_equals">true</boolProp>
<stringProp name="Argument.name">Accept</stringProp>
</elementProp>
</collectionProp>
</elementProp>
<stringProp name="HTTPSampler.domain"></stringProp>
<stringProp name="HTTPSampler.port"></stringProp>
<stringProp name="HTTPSampler.protocol"></stringProp>
<stringProp name="HTTPSampler.contentEncoding"></stringProp>
<stringProp name="HTTPSampler.path">/Plone/${testfolder-read}/folder-with-10-items-next-prev-enabled/doc5</stringProp>
<stringProp name="HTTPSampler.method">GET</stringProp>
<boolProp name="HTTPSampler.follow_redirects">true</boolProp>
<boolProp name="HTTPSampler.auto_redirects">false</boolProp>
<boolProp name="HTTPSampler.use_keepalive">true</boolProp>
<boolProp name="HTTPSampler.DO_MULTIPART_POST">false</boolProp>
<stringProp name="HTTPSampler.embedded_url_re"></stringProp>
<stringProp name="HTTPSampler.connect_timeout"></stringProp>
<stringProp name="HTTPSampler.response_timeout"></stringProp>
</HTTPSamplerProxy>
<hashTree/>
<HTTPSamplerProxy guiclass="HttpTestSampleGui" testclass="HTTPSamplerProxy" testname="News Item" enabled="true">
<elementProp name="HTTPsampler.Arguments" elementType="Arguments" guiclass="HTTPArgumentsPanel" testclass="Arguments" testname="Benutzer definierte Variablen" enabled="true">
<collectionProp name="Arguments.arguments">
Expand Down Expand Up @@ -901,6 +928,33 @@
<stringProp name="HTTPSampler.response_timeout"></stringProp>
</HTTPSamplerProxy>
<hashTree/>
<HTTPSamplerProxy guiclass="HttpTestSampleGui" testclass="HTTPSamplerProxy" testname="Document (next/prev)" enabled="true">
<elementProp name="HTTPsampler.Arguments" elementType="Arguments" guiclass="HTTPArgumentsPanel" testclass="Arguments" testname="Benutzer definierte Variablen" enabled="true">
<collectionProp name="Arguments.arguments">
<elementProp name="Accept" elementType="HTTPArgument">
<boolProp name="HTTPArgument.always_encode">false</boolProp>
<stringProp name="Argument.value">application/json</stringProp>
<stringProp name="Argument.metadata">=</stringProp>
<boolProp name="HTTPArgument.use_equals">true</boolProp>
<stringProp name="Argument.name">Accept</stringProp>
</elementProp>
</collectionProp>
</elementProp>
<stringProp name="HTTPSampler.domain"></stringProp>
<stringProp name="HTTPSampler.port"></stringProp>
<stringProp name="HTTPSampler.protocol"></stringProp>
<stringProp name="HTTPSampler.contentEncoding"></stringProp>
<stringProp name="HTTPSampler.path">/Plone/${testfolder-read}/folder-with-10-items-next-prev-enabled/doc5</stringProp>
<stringProp name="HTTPSampler.method">GET</stringProp>
<boolProp name="HTTPSampler.follow_redirects">true</boolProp>
<boolProp name="HTTPSampler.auto_redirects">false</boolProp>
<boolProp name="HTTPSampler.use_keepalive">true</boolProp>
<boolProp name="HTTPSampler.DO_MULTIPART_POST">false</boolProp>
<stringProp name="HTTPSampler.embedded_url_re"></stringProp>
<stringProp name="HTTPSampler.connect_timeout"></stringProp>
<stringProp name="HTTPSampler.response_timeout"></stringProp>
</HTTPSamplerProxy>
<hashTree/>
<HTTPSamplerProxy guiclass="HttpTestSampleGui" testclass="HTTPSamplerProxy" testname="News Item" enabled="true">
<elementProp name="HTTPsampler.Arguments" elementType="Arguments" guiclass="HTTPArgumentsPanel" testclass="Arguments" testname="Benutzer definierte Variablen" enabled="true">
<collectionProp name="Arguments.arguments">
Expand Down
8 changes: 6 additions & 2 deletions performance/plone-5.2-py3-imac-pro-20191122/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,10 @@ make test-performance

# Performance Test Plone 5.2 / Python 3

Hardware: iMac Pro
Hardware: iMac Pro (2017), 3,2 GHz-8-Core Inel Xeon W, 32 GB DDR4 RAM
Date: 20191123


Hardware: iMac Pro (2017), 3,2 GHz-8-Core Inel Xeon W, 32 GB DDR4 RAM, iOS Catalina 10.15.4
Date: 20200401


Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
5 changes: 3 additions & 2 deletions plone-5.2.x-performance.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ profiles =
plonetheme.barceloneta:default
plone.app.contenttypes:plone-content
plone.restapi:performance
upgrade-portal = False
upgrade-all-profiles = False
site-replace = True

[versions]
plone.restapi =
4 changes: 3 additions & 1 deletion plone-5.2.x.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,6 @@ extends =
http://dist.plone.org/release/5.2.1/versions.cfg
base.cfg
find-links += http://dist.plone.org/thirdparty/
versions=versions

[versions]
plone.restapi =
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

import sys

version = '6.4.2.dev0'
version = '6.6.1.dev0'


def read(filename):
Expand Down
8 changes: 8 additions & 0 deletions src/plone/restapi/serializer/atcontent.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
from plone.restapi.interfaces import ISerializeToJson
from plone.restapi.interfaces import ISerializeToJsonSummary
from plone.restapi.serializer.expansion import expandable_elements
from plone.restapi.serializer.nextprev import NextPrevious
from Products.Archetypes.interfaces import IBaseFolder
from Products.Archetypes.interfaces import IBaseObject
from Products.CMFCore.utils import getToolByName
Expand Down Expand Up @@ -51,6 +52,13 @@ def __call__(self, version=None, include_items=False):
"is_folderish": False,
}

# Insert next/prev information
nextprevious = NextPrevious(obj)
result.update({
"previous_item": nextprevious.previous,
"next_item": nextprevious.next,
})

# Insert expandable elements
result.update(expandable_elements(self.context, self.request))

Expand Down
8 changes: 8 additions & 0 deletions src/plone/restapi/serializer/dxcontent.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
from plone.restapi.interfaces import ISerializeToJsonSummary
from plone.restapi.serializer.converters import json_compatible
from plone.restapi.serializer.expansion import expandable_elements
from plone.restapi.serializer.nextprev import NextPrevious
from plone.rfc822.interfaces import IPrimaryFieldInfo
from plone.supermodel.utils import mergedTaggedValueDict
from Products.CMFCore.utils import getToolByName
Expand Down Expand Up @@ -67,6 +68,13 @@ def __call__(self, version=None, include_items=True):
"is_folderish": False,
}

# Insert next/prev information
nextprevious = NextPrevious(obj)
result.update({
"previous_item": nextprevious.previous,
"next_item": nextprevious.next,
})

# Insert expandable elements
result.update(expandable_elements(self.context, self.request))

Expand Down
Loading

0 comments on commit 39fc48d

Please sign in to comment.