Skip to content

Commit

Permalink
Merge 4e02f9e into 3ce625a
Browse files Browse the repository at this point in the history
  • Loading branch information
petschki committed Mar 26, 2019
2 parents 3ce625a + 4e02f9e commit 3937eeb
Show file tree
Hide file tree
Showing 4 changed files with 32 additions and 38 deletions.
3 changes: 2 additions & 1 deletion CHANGES.rst
Expand Up @@ -14,7 +14,8 @@ New features:

Bug fixes:

- *add item here*
- Python 3 compatible urllib imports
[petschki]


3.1.1 (2019-02-10)
Expand Down
46 changes: 24 additions & 22 deletions 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')
Expand Down Expand Up @@ -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

Expand All @@ -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
Expand All @@ -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)
Expand Down Expand Up @@ -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

Expand All @@ -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)
Expand Down Expand Up @@ -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

Expand All @@ -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)
Expand Down Expand Up @@ -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

Expand All @@ -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)
Expand Down Expand Up @@ -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

Expand All @@ -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)
Expand Down
11 changes: 5 additions & 6 deletions plone/app/tiles/utils.py
Expand Up @@ -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:
Expand All @@ -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,)

Expand All @@ -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:
Expand Down
10 changes: 1 addition & 9 deletions test-5.2.cfg
Expand Up @@ -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

0 comments on commit 3937eeb

Please sign in to comment.