Skip to content

Commit ae90f0e

Browse files
authored
Remove Plone < 5.2 and Python < 3 code. (#1171)
* WIP: Remove Plone < 5.2 and Python < 3 code. * Apply black. * Update changelog.
1 parent 709dbaa commit ae90f0e

39 files changed

+89
-967
lines changed

Makefile

Lines changed: 0 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,6 @@ help: ## This help message
2424
update: ## Update Make and Buildout
2525
wget -O Makefile https://raw.githubusercontent.com/kitconcept/buildout/master/Makefile
2626
wget -O requirements.txt https://raw.githubusercontent.com/kitconcept/buildout/master/requirements.txt
27-
wget -O plone-4.3.x.cfg https://raw.githubusercontent.com/kitconcept/buildout/master/plone-4.3.x.cfg
28-
wget -O plone-5.1.x.cfg https://raw.githubusercontent.com/kitconcept/buildout/master/plone-5.1.x.cfg
2927
wget -O plone-5.2.x.cfg https://raw.githubusercontent.com/kitconcept/buildout/master/plone-5.2.x.cfg
3028
wget -O ci.cfg https://raw.githubusercontent.com/kitconcept/buildout/master/ci.cfg
3129
wget -O versions.cfg https://raw.githubusercontent.com/kitconcept/buildout/master/versions.cfg
@@ -42,35 +40,6 @@ bin/buildout: bin/pip
4240
bin/python bin/pip:
4341
python$(version) -m venv . || virtualenv --python=python$(version) .
4442

45-
py2:
46-
virtualenv --python=python2 .
47-
bin/pip install --upgrade pip
48-
bin/pip install -r requirements.txt
49-
50-
.PHONY: Build Plone 4.3
51-
build-plone-4.3: py2 ## Build Plone 4.3
52-
bin/pip install --upgrade pip
53-
bin/pip install -r requirements.txt
54-
bin/buildout -c plone-4.3.x.cfg
55-
56-
.PHONY: Build Plone 5.0
57-
build-plone-5.0: py2 ## Build Plone 5.0
58-
bin/pip install --upgrade pip
59-
bin/pip install -r requirements.txt
60-
bin/buildout -c plone-5.0.x.cfg
61-
62-
.PHONY: Build Plone 5.1
63-
build-plone-5.1: py2 ## Build Plone 5.1
64-
bin/pip install --upgrade pip
65-
bin/pip install -r requirements.txt
66-
bin/buildout -c plone-5.1.x.cfg
67-
68-
.PHONY: Build Plone 5.2 with Python 2
69-
build-plone-5.2-py: py2 ## Build Plone 5.2 with Python 2
70-
bin/pip install --upgrade pip
71-
bin/pip install -r requirements.txt
72-
bin/buildout -c plone-5.2.x.cfg
73-
7443
.PHONY: Build Plone 5.2
7544
build-plone-5.2: .installed.cfg ## Build Plone 5.2
7645
bin/pip install --upgrade pip

news/1140.feature

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
Remove Python 2, Plone 4.3, and 5.1 code.
2+
[ericof]

src/plone/restapi/batching.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
from plone.batching.batch import Batch
22
from plone.restapi.deserializer import json_body
3-
from six.moves.urllib.parse import parse_qsl
4-
from six.moves.urllib.parse import urlencode
3+
from urllib.parse import parse_qsl
4+
from urllib.parse import urlencode
55

66

77
DEFAULT_BATCH_SIZE = 25

src/plone/restapi/controlpanels/types.py

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,17 +13,14 @@
1313
import plone.protect.interfaces
1414
from zope.interface import noLongerProvides
1515
from plone.restapi.interfaces import IPloneRestapiLayer
16-
from Products.CMFPlone.utils import getFSVersionTuple
17-
18-
PLONE5 = getFSVersionTuple()[0] >= 5
1916

2017

2118
@adapter(Interface, IPloneRestapiLayer)
2219
@implementer(IDexterityTypesControlpanel)
2320
class DexterityTypesControlpanel(RegistryConfigletPanel):
2421
schema = Interface
2522
configlet_id = "dexterity-types"
26-
configlet_category_id = "plone-content" if PLONE5 else "Plone"
23+
configlet_category_id = "plone-content"
2724

2825
def add(self, names):
2926
data = json_body(self.request)

src/plone/restapi/demo/demo.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33

44
class InternalServerErrorView(BrowserView): # pragma: no cover
55
def __call__(self):
6-
from six.moves.urllib.error import HTTPError
6+
from urllib.error import HTTPError
77

88
raise HTTPError(
99
"http://nohost/plone/internal_server_error",

src/plone/restapi/deserializer/dxfields.py

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,6 @@
2727

2828
import codecs
2929
import dateutil
30-
import six
3130

3231
import html as html_parser
3332

@@ -264,8 +263,6 @@ def __call__(self, value):
264263

265264
# Convert if we have data
266265
if data:
267-
if six.PY2:
268-
content_type = content_type.encode("utf8")
269266
value = self.field._type(
270267
data=data, contentType=content_type, filename=filename
271268
)

src/plone/restapi/deserializer/mixins.py

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,6 @@
33
from Products.CMFPlone.interfaces.siteroot import IPloneSiteRoot
44
from zExceptions import BadRequest
55

6-
import six
7-
86

97
class OrderingMixin:
108
def handle_ordering(self, data):
@@ -41,16 +39,6 @@ def reorderItems(self, obj_id, delta, subset_ids):
4139
if subset_ids != [i for position, i in position_id]:
4240
raise BadRequest("Client/server ordering mismatch")
4341

44-
# Make sure we use bytestring ids for PY2.
45-
if six.PY2:
46-
if isinstance(obj_id, str):
47-
obj_id = obj_id.encode("utf-8")
48-
if subset_ids:
49-
subset_ids = [
50-
id_.encode("utf-8") if isinstance(id_, str) else id_
51-
for id_ in subset_ids
52-
]
53-
5442
# All movement is relative to the subset of ids, if passed in.
5543
if delta == "top":
5644
ordering.moveObjectsToTop([obj_id], subset_ids=subset_ids)

src/plone/restapi/deserializer/relationfield.py

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,6 @@
1010
from zope.intid.interfaces import IIntIds
1111
from zope.publisher.interfaces.browser import IBrowserRequest
1212

13-
import six
14-
1513

1614
@implementer(IFieldDeserializer)
1715
@adapter(IRelationChoice, IDexterityContent, IBrowserRequest)
@@ -30,8 +28,6 @@ def __call__(self, value):
3028
obj = intids.queryObject(value)
3129
resolved_by = "intid"
3230
elif isinstance(value, str):
33-
if six.PY2 and isinstance(value, str):
34-
value = value.encode("utf8")
3531
portal = getMultiAdapter(
3632
(self.context, self.request), name="plone_portal_state"
3733
).portal()

src/plone/restapi/pas/plugin.py

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@
1818
from zope.interface import implementer
1919

2020
import jwt
21-
import six
2221
import time
2322

2423

@@ -119,8 +118,6 @@ def authenticateCredentials(self, credentials):
119118
return
120119

121120
userid = payload["sub"]
122-
if six.PY2:
123-
userid = userid.encode("utf8")
124121

125122
if self.store_tokens:
126123
if userid not in self._tokens:

src/plone/restapi/search/handler.py

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -3,19 +3,11 @@
33
from plone.restapi.interfaces import IZCatalogCompatibleQuery
44
from Products.CMFCore.utils import getToolByName
55
from Products.CMFPlone.browser.navtree import getNavigationRoot
6+
from Products.CMFPlone.interfaces import ISearchSchema
67
from zope.component import getMultiAdapter
78
from zope.component import getUtility
89

910

10-
try:
11-
from Products.CMFPlone.factory import _IMREALLYPLONE5 # noqa
12-
from Products.CMFPlone.interfaces import ISearchSchema
13-
except ImportError:
14-
PLONE5 = False
15-
else:
16-
PLONE5 = True
17-
18-
1911
class SearchHandler:
2012
"""Executes a catalog search based on a query dict, and returns
2113
JSON compatible results.
@@ -91,7 +83,7 @@ def search(self, query=None):
9183
use_site_search_settings = True
9284
del query["use_site_search_settings"]
9385

94-
if PLONE5 and use_site_search_settings:
86+
if use_site_search_settings:
9587
query = self.filter_query(query)
9688

9789
self._constrain_query_by_path(query)

0 commit comments

Comments
 (0)