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

Remove deprecated token parameter from vocabularies endpoint #1701

Closed
wants to merge 2 commits into from
Closed
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
1 change: 1 addition & 0 deletions news/1697.breaking
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Remove deprecated token parameter from vocabularies endpoint. @tisto
17 changes: 3 additions & 14 deletions src/plone/restapi/serializer/vocabularies.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,6 @@
from zope.schema.interfaces import ITokenizedTerm
from zope.schema.interfaces import IVocabulary

import warnings


@implementer(ISerializeToJson)
class SerializeVocabLikeToJson:
Expand All @@ -28,30 +26,21 @@ def __init__(self, context, request):
def __call__(self, vocabulary_id):
vocabulary = self.context
title = safe_text(self.request.form.get("title", ""))
token = self.request.form.get("token", "")
tokens = self.request.form.get("tokens", [])
b_size = self.request.form.get("b_size", "")

terms = []
for term in vocabulary:
if title and token:
if title and tokens:
self.request.response.setStatus(400)
return dict(
error=dict(
type="Invalid parameters",
message="You can not filter by title and token at the same time.",
message="You can not filter by title and tokens at the same time.",
) # noqa
)

if token:
warnings.warn(
"``token`` parameter is deprecated and will be removed in plone.restapi 9.0. Use ``tokens`` parameter instead.",
DeprecationWarning,
)
if token.lower() != term.token.lower():
continue
terms.append(term)
elif tokens:
if tokens:
if isinstance(tokens, str):
tokens = [tokens]
for item in tokens:
Expand Down