diff --git a/CHANGES.rst b/CHANGES.rst index 6050ad5..5be148e 100644 --- a/CHANGES.rst +++ b/CHANGES.rst @@ -14,7 +14,8 @@ New features: Bug fixes: -- *add item here* +- Python 3 compatible urllib imports + [petschki] 3.1.1 (2019-02-10) diff --git a/plone/app/tiles/tests/_test_drafting.py b/plone/app/tiles/tests/_test_drafting.py index bf306d4..653f1b2 100644 --- a/plone/app/tiles/tests/_test_drafting.py +++ b/plone/app/tiles/tests/_test_drafting.py @@ -1,13 +1,14 @@ # -*- coding: utf-8 -*- -import urllib import pkg_resources + from plone.app.testing import SITE_OWNER_NAME from plone.app.testing import SITE_OWNER_PASSWORD +from plone.app.tiles.testing import PLONE_APP_TILES_FUNCTIONAL_TESTING from plone.testing.z2 import Browser +from plone.tiles.data import ANNOTATIONS_KEY_PREFIX +from six.moves.urllib import parse as urlparse from zope.annotation.interfaces import IAnnotations from zope.component import getUtility -from plone.app.tiles.testing import PLONE_APP_TILES_FUNCTIONAL_TESTING -from plone.tiles.data import ANNOTATIONS_KEY_PREFIX try: pkg_resources.get_distribution('plone.app.drafts') @@ -79,9 +80,9 @@ def test_persistent_drafting(self): cookies = self.browser.cookies.forURL(baseURL) - targetKey = urllib.unquote( + targetKey = urlparse.unquote( cookies['plone.app.drafts.targetKey'].replace('"', '')) - cookiePath = urllib.unquote( + cookiePath = urlparse.unquote( cookies['plone.app.drafts.path'].replace('"', '')) draftName = None @@ -91,13 +92,14 @@ def test_persistent_drafting(self): # an AJAX request for the same e.g. in a pop-up dialogue box self.browser.open(baseURL + '/@@add-tile') - self.browser.getControl(name='tiletype').value = \ - ['plone.app.tiles.demo.persistent'] + self.browser.getControl( + name='tiletype').value = ['plone.app.tiles.demo.persistent'] self.browser.getControl(name='form.button.Create').click() # Fill in the data and save - self.browser.getControl(name='plone.app.tiles.demo.persistent.message')\ - .value = 'Test message' + self.browser.getControl( + name='plone.app.tiles.demo.persistent.message').value = 'Test message' # noqa: E501 + import pdb; pdb.set_trace() self.browser.getControl( name='plone.app.tiles.demo.persistent.counter').value = '1' # XXX @@ -110,7 +112,7 @@ def test_persistent_drafting(self): # We should now have a draft for this item with the relevant # annotations - draftName = urllib.unquote( + draftName = urlparse.unquote( cookies['plone.app.drafts.draftName'].replace('"', '')) draft = drafts.getDraft(SITE_OWNER_NAME, targetKey, draftName) @@ -195,9 +197,9 @@ def test_persistent_drafting(self): # Get the values of the drafting cookies cookies = self.browser.cookies.forURL(baseURL) - targetKey = urllib.unquote( + targetKey = urlparse.unquote( cookies['plone.app.drafts.targetKey'].replace('"', '')) - cookiePath = urllib.unquote( + cookiePath = urlparse.unquote( cookies['plone.app.drafts.path'].replace('"', '')) draftName = None @@ -213,7 +215,7 @@ def test_persistent_drafting(self): # A draft should now have been created - draftName = urllib.unquote( + draftName = urlparse.unquote( cookies['plone.app.drafts.draftName'].replace('"', '')) draft = drafts.getDraft(SITE_OWNER_NAME, targetKey, draftName) draftAnnotations = IAnnotations(draft) @@ -264,9 +266,9 @@ def test_persistent_drafting(self): contextAnnotations = IAnnotations(context) cookies = self.browser.cookies.forURL(baseURL) - targetKey = urllib.unquote( + targetKey = urlparse.unquote( cookies['plone.app.drafts.targetKey'].replace('"', '')) - cookiePath = urllib.unquote( + cookiePath = urlparse.unquote( cookies['plone.app.drafts.path'].replace('"', '')) draftName = None @@ -276,7 +278,7 @@ def test_persistent_drafting(self): self.browser.getControl(label='Save').click() # A draft should now have been created - draftName = urllib.unquote( + draftName = urlparse.unquote( cookies['plone.app.drafts.draftName'].replace('"', '')) draft = drafts.getDraft(SITE_OWNER_NAME, targetKey, draftName) draftAnnotations = IAnnotations(draft) @@ -322,9 +324,9 @@ def test_persistent_drafting(self): contextAnnotations = IAnnotations(context) cookies = self.browser.cookies.forURL(baseURL) - targetKey = urllib.unquote( + targetKey = urlparse.unquote( cookies['plone.app.drafts.targetKey'].replace('"', '')) - cookiePath = urllib.unquote( + cookiePath = urlparse.unquote( cookies['plone.app.drafts.path'].replace('"', '')) draftName = None @@ -342,7 +344,7 @@ def test_persistent_drafting(self): self.browser.getControl(name='deleted.type').value) # Draft should have been created - draftName = urllib.unquote( + draftName = urlparse.unquote( cookies['plone.app.drafts.draftName'].replace('"', '')) draft = drafts.getDraft(SITE_OWNER_NAME, targetKey, draftName) draftAnnotations = IAnnotations(draft) @@ -392,9 +394,9 @@ def test_persistent_drafting(self): contextAnnotations = IAnnotations(context) cookies = self.browser.cookies.forURL(baseURL) - targetKey = urllib.unquote( + targetKey = urlparse.unquote( cookies['plone.app.drafts.targetKey'].replace('"', '')) - cookiePath = urllib.unquote( + cookiePath = urlparse.unquote( cookies['plone.app.drafts.path'].replace('"', '')) draftName = None @@ -412,7 +414,7 @@ def test_persistent_drafting(self): self.browser.getControl(name='deleted.type').value) # Draft should have been created - draftName = urllib.unquote( + draftName = urlparse.unquote( cookies['plone.app.drafts.draftName'].replace('"', '')) draft = drafts.getDraft(SITE_OWNER_NAME, targetKey, draftName) draftAnnotations = IAnnotations(draft) diff --git a/plone/app/tiles/utils.py b/plone/app/tiles/utils.py index 5138a6e..257a161 100644 --- a/plone/app/tiles/utils.py +++ b/plone/app/tiles/utils.py @@ -2,12 +2,11 @@ from plone.tiles.interfaces import IPersistentTile from plone.tiles.interfaces import ITileDataManager from plone.tiles.interfaces import ITileType +from six.moves.urllib import parse as urlparse from zope.component import getMultiAdapter from zope.component import queryUtility from zope.traversing.browser.interfaces import IAbsoluteURL -import urllib - try: import json except ImportError: @@ -34,9 +33,9 @@ def getEditTileURL(tile, request): url = str(getMultiAdapter((context, request), IAbsoluteURL)) - tileFragment = "@@edit-tile/" + urllib.quote(name.encode('utf-8'), _safe) + tileFragment = "@@edit-tile/" + urlparse.quote(name.encode('utf-8'), _safe) if id: - tileFragment += '/' + urllib.quote(id.encode('utf-8'), _safe) + tileFragment += '/' + urlparse.quote(id.encode('utf-8'), _safe) url = '%s/%s' % (url, tileFragment,) @@ -59,9 +58,9 @@ def appendJSONData(url, key='#', data=None): if data is None: return url elif key == '#' or not key: - return url + '#' + urllib.quote(json.dumps(data)) + return url + '#' + urlparse.quote(json.dumps(data)) else: - quoted = "%s=%s" % (key, urllib.quote(json.dumps(data)),) + quoted = "%s=%s" % (key, urlparse.quote(json.dumps(data)),) if '?' in url: return url + '&' + quoted else: diff --git a/test-5.2.cfg b/test-5.2.cfg index 7b4cca1..9284721 100644 --- a/test-5.2.cfg +++ b/test-5.2.cfg @@ -5,20 +5,12 @@ extends = base.cfg extensions = mr.developer -auto-checkout = - plone.app.drafts - plone.subrequest - -[sources] -plone.app.drafts = git git://github.com/plone/plone.app.drafts.git branch=py3plone52 -plone.subrequest = git git://github.com/plone/plone.subrequest.git branch=master +versions = versions [versions] setuptools = zc.buildout = coverage = >=3.7 -plone.app.drafts = plone.behavior = >=1.1 -plone.subrequest = plone.tiles = >=2.2.0