Skip to content

Commit

Permalink
Merge pull request #73 from plone/python3-configparser-multidict-fix
Browse files Browse the repository at this point in the history
fix multidict feature for python 3
  • Loading branch information
jensens committed Feb 20, 2019
2 parents d6a1c69 + ec11044 commit abf65fe
Show file tree
Hide file tree
Showing 4 changed files with 53 additions and 22 deletions.
15 changes: 2 additions & 13 deletions CHANGES.rst
Expand Up @@ -4,26 +4,15 @@ Changelog
4.3.1 (unreleased)
------------------

Breaking changes:

- *add item here*

New features:

- *add item here*

Bug fixes:

- *add item here*
- fix multidict feature for python 3
[petschki]


4.3.0 (2019-02-10)
------------------

Breaking changes:

- Nothing changed yet.

Bug fixes:

- Enforce usage of plone.subrequest >= 1.7.0;
Expand Down
14 changes: 13 additions & 1 deletion plone/app/blocks/resource.py
Expand Up @@ -37,6 +37,18 @@
import logging
import six

try:
from configparser import DEFAULTSECT
from configparser import SectionProxy

except ImportError:
# python 2.7 fallback for multidict

class SectionProxy(dict):
pass

DEFAULTSECT = None

logger = logging.getLogger('plone.app.blocks')


Expand Down Expand Up @@ -73,7 +85,7 @@ class multidict(dict):
_unique = 0

def __setitem__(self, key, val):
if isinstance(val, dict):
if isinstance(val, (dict, SectionProxy)) and key != DEFAULTSECT:
self._unique += 1
key += str(self._unique)
dict.__setitem__(self, key, val)
Expand Down
35 changes: 35 additions & 0 deletions plone/app/blocks/tests/test_resource.py
@@ -0,0 +1,35 @@
# -*- coding: utf-8 -*-
import unittest

from plone.app.blocks.resource import getLayoutsFromResources
from plone.app.blocks.testing import BLOCKS_FUNCTIONAL_TESTING
from plone.app.blocks.interfaces import SITE_LAYOUT_MANIFEST_FORMAT
from plone.app.blocks.interfaces import CONTENT_LAYOUT_MANIFEST_FORMAT


class TestResource(unittest.TestCase):

layer = BLOCKS_FUNCTIONAL_TESTING

def setUp(self):
self.portal = self.layer['portal']

def test_contentlayout_manifest(self):
layouts = getLayoutsFromResources(CONTENT_LAYOUT_MANIFEST_FORMAT)
self.assertTrue('testlayout1/content.html' in layouts)
self.assertTrue('testlayout2/mylayout.html' in layouts)
self.assertTrue('testlayout2/mylayout2.html' in layouts)

self.assertTrue(layouts['testlayout1/content.html']['title'] == 'Testlayout1') # noqa
self.assertTrue(layouts['testlayout2/mylayout.html']['title'] == 'My content layout') # noqa
self.assertTrue(layouts['testlayout2/mylayout2.html']['title'] == 'My content layout 2') # noqa

def test_sitelayout_manifest(self):
layouts = getLayoutsFromResources(SITE_LAYOUT_MANIFEST_FORMAT)
self.assertTrue('testlayout1/site.html' in layouts)
self.assertTrue('testlayout2/mylayout.html' in layouts)
self.assertTrue('testlayout2/mylayout2.html' in layouts)

self.assertTrue(layouts['testlayout1/site.html']['title'] == 'Testlayout1') # noqa
self.assertTrue(layouts['testlayout2/mylayout.html']['title'] == 'My site layout') # noqa
self.assertTrue(layouts['testlayout2/mylayout2.html']['title'] == 'My site layout 2') # noqa
11 changes: 3 additions & 8 deletions test-5.2.x.cfg
Expand Up @@ -8,21 +8,16 @@ parts +=

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

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

[versions]
setuptools =
zc.buildout =
coverage = >=3.7
plone.behavior = >=1.1
plone.app.blocks =
plone.app.tiles =
plone.subrequest =
plone.app.tiles = >= 3.1.1
plone.subrequest = >= 1.9.0
plone.jsonserializer = >= 0.9.7
plone.tiles = >=2.2.0

0 comments on commit abf65fe

Please sign in to comment.