diff --git a/.gitignore b/.gitignore index 8897b875..990c192d 100644 --- a/.gitignore +++ b/.gitignore @@ -17,3 +17,4 @@ local/ parts/ var/ src/ +/pip-selfcheck.json diff --git a/CHANGES.rst b/CHANGES.rst index 8ea64eff..a8dae514 100644 --- a/CHANGES.rst +++ b/CHANGES.rst @@ -5,6 +5,8 @@ Changelog ------------------ Bug fixes: +- Catch errors on resolving tiles and return an error message instead of breaking the whole UI + [MrTango] - Fix issue where layout aware tile data storage read cache was not purged when data was updated programmatically [fixes #75] diff --git a/buildout.cfg b/buildout.cfg index 9960ae37..8ef20284 100644 --- a/buildout.cfg +++ b/buildout.cfg @@ -1,6 +1,6 @@ [buildout] extends = - test-x.x.x.cfg + test-5.2.x.cfg package-name = plone.app.blocks package-extras = [test] diff --git a/plone/app/blocks/tests/test_tiles.py b/plone/app/blocks/tests/test_tiles.py index 219e8ce1..f245434c 100644 --- a/plone/app/blocks/tests/test_tiles.py +++ b/plone/app/blocks/tests/test_tiles.py @@ -13,6 +13,13 @@ import unittest +try: + # Python 2: "unicode" is built-in + unicode +except NameError: + unicode = str + + class ITestTile(Interface): magicNumber = schema.Int(title=u"Magic number", required=False) @@ -35,6 +42,7 @@ def __call__(self):

Magic number: %(number)d; Form: %(form)s; Query string: %(queryString)s; URL: %(url)s + Umlauts: Übertile ;)

""" % dict(name=self.id, number=self.data['magicNumber'] or -1, @@ -221,10 +229,11 @@ def testRenderTiles(self): request = self.layer['request'] tree = serializer.tree renderTiles(request, tree) - result = str(serializer) + result = unicode(serializer) self.assertIn('This is a demo tile with id tile2', result) self.assertIn('This is a demo tile with id tile3', result) self.assertIn('This is a demo tile with id tile4', result) + self.assertIn(u'Umlauts: \xdcbertile', result) def testRenderTilesError(self): serializer = getHTMLSerializer([testLayout2]) @@ -234,7 +243,7 @@ def testRenderTilesError(self): result = str(serializer) self.assertIn('This is a demo tile with id tile2', result) self.assertNotIn('This is a demo tile with id tile3', result) - self.assertIn('There was an error while rendering this tile', result) + self.assertIn('There was an error', result) self.assertIn('This is a demo tile with id tile4', result) def testRenderSubTiles(self): diff --git a/plone/app/blocks/utils.py b/plone/app/blocks/utils.py index d51dfa40..eafae97e 100644 --- a/plone/app/blocks/utils.py +++ b/plone/app/blocks/utils.py @@ -69,9 +69,31 @@ def extractCharset(response, default='utf-8'): def resolve(url, resolved=None): """Resolve the given URL to an lxml tree. """ - if resolved is None: - resolved = resolveResource(url) + try: + resolved = resolveResource(url) + except Exception: + logger.exception( + 'There was an error while resolving the tile: {0}'.format( + url, + ), + ) + scheme, netloc, path, params, query, fragment = parse.urlparse(url) + tile_parts = { + 'scheme': scheme, + 'netloc': netloc, + 'path': path, + } + resolved = """ + + + + +""".format(**tile_parts) + if not resolved.strip(): return None try: diff --git a/test-5.2.x.cfg b/test-5.2.x.cfg index f3d1b76d..8d9ac3c8 100644 --- a/test-5.2.x.cfg +++ b/test-5.2.x.cfg @@ -7,9 +7,17 @@ parts += createcoverage extensions = mr.developer -auto-checkout = +auto-checkout = plone.subrequest + +[remotes] +plone = https://github.com/plone +plone-push = git+ssh://git@github.com/plone +collective = https://github.com/collective +collective-push = git+ssh://git@github.com/collective [sources] +plone.subrequest = git ${remotes:plone}/plone.subrequest.git pushurl=${remotes:plone-push}/plone.subrequest.git + [versions] setuptools =