Skip to content

Commit

Permalink
Merge a4ea059 into 9f5c18c
Browse files Browse the repository at this point in the history
  • Loading branch information
petschki committed Dec 3, 2018
2 parents 9f5c18c + a4ea059 commit b8eb81c
Show file tree
Hide file tree
Showing 20 changed files with 180 additions and 99 deletions.
25 changes: 18 additions & 7 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,23 +1,34 @@
language: python
python: 2.7
sudo: false
env:
- PLONE_VERSION=4.x
- PLONE_VERSION=5.x
matrix:
include:
- python: "2.7"
env: PLONE_VERSION=4.3.x
- python: "2.7"
env: PLONE_VERSION=5.0.x
- python: "2.7"
env: PLONE_VERSION=5.1.x
- python: "2.7"
env: PLONE_VERSION=5.2.x
- python: "3.6"
env: PLONE_VERSION=5.2.x
- python: "3.7"
env: PLONE_VERSION=5.2.x
dist: xenial
sudo: true
fast_finish: true
cache:
pip: true
directories:
- $HOME/buildout-cache
matrix:
fast_finish: true
before_install:
- mkdir -p $HOME/buildout-cache/{eggs,downloads}
- mkdir $HOME/.buildout
- echo "[buildout]" > $HOME/.buildout/default.cfg
- echo "download-cache = $HOME/buildout-cache/downloads" >> $HOME/.buildout/default.cfg
- echo "eggs-directory = $HOME/buildout-cache/eggs" >> $HOME/.buildout/default.cfg
- pip install zc.buildout
- sed -ie "s#test-4.x.cfg#test-$PLONE_VERSION.cfg#" buildout.cfg
- sed -ie "s#test-x.x.x.cfg#test-$PLONE_VERSION.cfg#" buildout.cfg
install:
- buildout -N -t 3 annotate
- buildout -N -t 3
Expand Down
8 changes: 4 additions & 4 deletions CHANGES.rst
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
Changelog
=========

4.2.1 (unreleased)
4.3.0 (unreleased)
------------------

Breaking chnages:
Breaking changes:

- Nothing changed yet.

Expand All @@ -16,8 +16,8 @@ Bug fixes:

New features:

- Nothing changed yet.

- python3 compatibility
[petschki]

4.2.0 (2018-07-02)
------------------
Expand Down
25 changes: 1 addition & 24 deletions buildout.cfg
Original file line number Diff line number Diff line change
@@ -1,33 +1,10 @@
[buildout]
extends =
https://raw.githubusercontent.com/collective/buildout.plonetest/master/test-4.x.cfg
https://raw.githubusercontent.com/collective/buildout.plonetest/master/qa.cfg
test-x.x.x.cfg

package-name = plone.app.blocks
package-extras = [test]

parts +=
createcoverage

extensions = mr.developer
auto-checkout =
plone.jsonserializer
plone.subrequest
plone.tiles

[sources]
plone.jsonserializer = git git://github.com/plone/plone.jsonserializer.git
plone.tiles = git git://github.com/plone/plone.tiles.git branch=master
plone.subrequest = git git://github.com/plone/plone.subrequest.git

[code-analysis]
directory = plone
flake8-ignore = E501,C901

[versions]
setuptools =
zc.buildout =
coverage = >=3.7
plone.behavior = >=1.1
plone.app.blocks =

7 changes: 4 additions & 3 deletions plone/app/blocks/indexing.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,9 @@
from zope.annotation.interfaces import IAnnotations
from zope.component import adapter
from zope.interface import implementer
import pkg_resources

import pkg_resources
import six

try:
pkg_resources.get_distribution('collective.dexteritytextindexer')
Expand All @@ -26,7 +27,7 @@
def concat(*args):
result = ''
for value in args:
if isinstance(value, unicode):
if isinstance(value, six.text_type):
value = value.encode('utf-8', 'replace')
if value:
result = ' '.join((result, value))
Expand Down Expand Up @@ -57,7 +58,7 @@ def LayoutSearchableText(obj):
data = annotations[key]
for field_name in ('title', 'label', 'content'):
val = data.get(field_name)
if isinstance(val, basestring):
if isinstance(val, six.string_types):
text.append(val)

try:
Expand Down
16 changes: 6 additions & 10 deletions plone/app/blocks/panel.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,6 @@
# -*- coding: utf-8 -*-
from plone.app.blocks import utils
from urllib import urlencode
from urlparse import parse_qs
from urlparse import urljoin
from urlparse import urlparse
from urlparse import urlunparse
from six.moves.urllib import parse


def merge(request, pageTree, removePanelLinks=False, removeLayoutLink=True):
Expand All @@ -23,15 +19,15 @@ def merge(request, pageTree, removePanelLinks=False, removeLayoutLink=True):
if request.getVirtualRoot():
# plone.subrequest deals with VHM requests
baseURL = ''
layoutHref = urljoin(baseURL, layoutHref) # turn the link absolute
layoutHref = parse.urljoin(baseURL, layoutHref) # noqa: turn the link absolute
# Pass special ajax_load parameter forward to allow layout indirection
# views to select, for example, default AJAX layout instead of full layout.
if request.form.get('ajax_load'):
parts = list(urlparse(layoutHref))
query = parse_qs(parts[4])
parts = list(parse.urlparse(layoutHref))
query = parse.parse_qs(parts[4])
query['ajax_load'] = request.form.get('ajax_load')
parts[4] = urlencode(query)
layoutHref = urlunparse(parts)
parts[4] = parse.urlencode(query)
layoutHref = parse.urlunparse(parts)
layoutTree = utils.resolve(layoutHref)
if layoutTree is None:
return None
Expand Down
10 changes: 5 additions & 5 deletions plone/app/blocks/resource.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
# -*- coding: utf-8 -*-
from Acquisition import aq_parent
from App.config import getConfiguration
from ConfigParser import SafeConfigParser
from OFS.interfaces import ITraversable
from Products.CMFCore.utils import getToolByName
from plone.app.blocks.interfaces import CONTENT_LAYOUT_FILE_NAME
from plone.app.blocks.interfaces import CONTENT_LAYOUT_MANIFEST_FORMAT
from plone.app.blocks.interfaces import CONTENT_LAYOUT_RESOURCE_NAME
Expand All @@ -21,7 +21,8 @@
from plone.resource.traversal import ResourceTraverser
from plone.resource.utils import iterDirectoriesOfType
from plone.subrequest import ISubRequest
from Products.CMFCore.utils import getToolByName
from six.moves.configparser import ConfigParser
from six.moves.urllib import parse
from zExceptions import NotFound
from zope.annotation import IAnnotations
from zope.component import adapter
Expand All @@ -34,7 +35,6 @@
from zope.site.hooks import getSite

import logging
import urlparse


logger = logging.getLogger('plone.app.blocks')
Expand Down Expand Up @@ -80,7 +80,7 @@ def __setitem__(self, key, val):


def getLayoutsFromManifest(fp, _format, directory_name):
parser = SafeConfigParser(None, multidict)
parser = ConfigParser(None, multidict)
parser.readfp(fp)

layouts = {}
Expand Down Expand Up @@ -277,7 +277,7 @@ def layout(self):

path = layout
if pathContext is not None:
path = urlparse.urljoin(pathContext.absolute_url_path(), layout)
path = parse.urljoin(pathContext.absolute_url_path(), layout)

return path

Expand Down
10 changes: 5 additions & 5 deletions plone/app/blocks/tests/context.rst
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,10 @@ and page layouts, respectively::
... </html>
... """ % self.context.Title()

>>> from zope.interface import implements
>>> from zope.interface import implementer
>>> from plone.app.blocks.interfaces import IBlocksTransformEnabled
>>> class PageLayout(BrowserView):
... implements(IBlocksTransformEnabled)
>>> @implementer(IBlocksTransformEnabled)
... class PageLayout(BrowserView):
... __name__ = 'page-layout'
... def __call__(self):
... return u"""
Expand All @@ -45,7 +45,7 @@ relative URL.
Next, we initialize and register the browser views as ZCML handlers would::

>>> from zope.interface import Interface
>>> from Products.Five.security import protectClass
>>> from AccessControl.security import protectClass
>>> protectClass(SiteLayout, 'zope2.View')
>>> protectClass(PageLayout, 'zope2.View')

Expand All @@ -67,7 +67,7 @@ the default title of the portal object, ``Plone site`` will be used::

>>> portal = layer['portal']
>>> browser.open(portal.absolute_url() + '/@@page-layout')
>>> print browser.contents
>>> print(browser.contents)
<!DOCTYPE html...
<title>Plone site</title>...
<div data-panel="content">Plone site</div>...
16 changes: 8 additions & 8 deletions plone/app/blocks/tests/esi.rst
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ Register these in the same way that the ZCML handlers would, more or less.

.. code-block:: python
>>> from Products.Five.security import protectClass
>>> from AccessControl.security import protectClass
>>> protectClass(NonESITile, 'zope2.View')
>>> protectClass(SimpleESITile, 'zope2.View')
Expand Down Expand Up @@ -144,10 +144,10 @@ instead just referencing a view containing the layout directly.
... </html>
... """
>>> from zope.interface import implements
>>> from zope.interface import implementer
>>> from plone.app.blocks.interfaces import IBlocksTransformEnabled
>>> class Page(BrowserView):
... implements(IBlocksTransformEnabled)
>>> @implementer(IBlocksTransformEnabled)
... class Page(BrowserView):
... __name__ = 'test-page'
... def __call__(self):
... return pageHTML
Expand Down Expand Up @@ -176,7 +176,7 @@ Some cleanup is needed to cover lxml platform discrepancies...

.. code-block:: python
>>> print browser.contents.replace('<head><meta', '<head>\n\t<meta')
>>> print(browser.contents.replace('<head><meta', '<head>\n\t<meta'))
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
Expand Down Expand Up @@ -230,7 +230,7 @@ tiles should be rendered as ESI links. See `plone.tiles`_ for more details.
.. code-block:: python
>>> browser.open(portal.absolute_url() + '/@@test-page')
>>> print browser.contents.replace('<head><meta', '<head>\n\t<meta')
>>> print(browser.contents.replace('<head><meta', '<head>\n\t<meta'))
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns:esi="http://www.edge-delivery.org/esi/1.0" xmlns="http://www.w3.org/1999/xhtml">
<head>
Expand Down Expand Up @@ -275,13 +275,13 @@ When ESI rendering takes place, the following URLs will be called:
.. code-block:: python
>>> browser.open("http://nohost/plone/@@test.tile3/tile4/@@esi-body?foo=bar")
>>> print browser.contents
>>> print(browser.contents)
<p>
ESI tile with query string foo=bar
</p>
>>> browser.open("http://nohost/plone/@@test.tile3/tile2/@@esi-body?")
>>> print browser.contents
>>> print(browser.contents)
<p>
ESI tile with query string
</p>
Expand Down
14 changes: 7 additions & 7 deletions plone/app/blocks/tests/rendering.rst
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ See ``plone.resource`` for more details.
>>> from Products.CMFCore.utils import getToolByName
>>> from Products.BTreeFolder2.BTreeFolder2 import BTreeFolder2
>>> from StringIO import StringIO
>>> from six import StringIO
>>> from OFS.Image import File
>>> resources = getToolByName(portal, 'portal_resources')
Expand All @@ -134,7 +134,7 @@ Let's render it on its own to verify that.
.. code-block:: python
>>> browser.open(portal.absolute_url() + '/++sitelayout++mylayout/site.html')
>>> print browser.contents
>>> print(browser.contents)
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
<head>
Expand Down Expand Up @@ -216,13 +216,13 @@ In real life, these could be registered using the standard ``<browser:page />``
.. code-block:: python
>>> from zope.publisher.browser import BrowserView
>>> from zope.interface import Interface, implements
>>> from zope.interface import Interface, implementer
>>> from zope import schema
>>> from plone.tiles import Tile
>>> from plone.app.blocks.interfaces import IBlocksTransformEnabled
>>> class Page(BrowserView):
... implements(IBlocksTransformEnabled)
>>> @implementer(IBlocksTransformEnabled)
... class Page(BrowserView):
... __name__ = 'test-page'
... def __call__(self):
... return pageHTML
Expand Down Expand Up @@ -272,7 +272,7 @@ We register these views and tiles in the same way the ZCML handlers for ``<brows
.. code-block:: python
>>> from plone.tiles.type import TileType
>>> from Products.Five.security import protectClass
>>> from AccessControl.security import protectClass
>>> from App.class_init import InitializeClass
>>> from zope.component import provideAdapter, provideUtility
>>> from zope.interface import Interface
Expand Down Expand Up @@ -314,7 +314,7 @@ We make sure that Zope is in "development mode" to get pretty-printed output.
.. code-block:: python
>>> browser.open(portal.absolute_url() + '/@@test-page')
>>> print browser.contents.replace('<head><meta', '<head>\n\t<meta')
>>> print(browser.contents.replace('<head><meta', '<head>\n\t<meta'))
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
Expand Down
2 changes: 1 addition & 1 deletion plone/app/blocks/tests/test_layoutbehavior.py
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@ class IRichTextTile(Schema):
)
}

self.assertEqual(unicode(storage.storage).replace(u'\n', u''), u"""\
self.assertEqual(str(storage.storage).replace(u'\n', u''), u"""\
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" "http://www.w3.org/TR/REC-html40/loose.dtd">
<html>
<body>
Expand Down
10 changes: 5 additions & 5 deletions plone/app/blocks/tests/test_sitelayout.py
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
# -*- coding: utf-8 -*-
from lxml import etree
from OFS.Image import File
from Products.BTreeFolder2.BTreeFolder2 import BTreeFolder2
from Products.CMFPlone.utils import getToolByName
from lxml import etree
from plone.app.blocks.interfaces import DEFAULT_SITE_LAYOUT_REGISTRY_KEY
from plone.app.blocks.testing import BLOCKS_FUNCTIONAL_TESTING
from plone.app.testing import setRoles
from plone.app.testing import TEST_USER_ID
from plone.app.testing import setRoles
from plone.memoize.volatile import ATTR
from plone.registry.interfaces import IRegistry
from Products.BTreeFolder2.BTreeFolder2 import BTreeFolder2
from Products.CMFPlone.utils import getToolByName
from StringIO import StringIO
from six import StringIO
from zExceptions import NotFound
from zope.component import adapter
from zope.component import getMultiAdapter
Expand Down

0 comments on commit b8eb81c

Please sign in to comment.