Skip to content

Commit

Permalink
Merge 8727995 into 5f24f7c
Browse files Browse the repository at this point in the history
  • Loading branch information
datakurre committed Nov 3, 2017
2 parents 5f24f7c + 8727995 commit 543a8fc
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 1 deletion.
6 changes: 6 additions & 0 deletions CHANGES.rst
Expand Up @@ -4,6 +4,12 @@ Changelog
4.1.2 (unreleased)
------------------

Bug fixes:

- Fix issue where resolving layout url with ajax_load parameter caused fail
on direct resolve directory lookup
[datakurre]

- Fix issue where failed resource lookup into filesystem resource directory
raised IOError
[datakurre]
Expand Down
2 changes: 2 additions & 0 deletions plone/app/blocks/panel.py
Expand Up @@ -24,6 +24,8 @@ def merge(request, pageTree, removePanelLinks=False, removeLayoutLink=True):
# plone.subrequest deals with VHM requests
baseURL = ''
layoutHref = urljoin(baseURL, layoutHref) # 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])
Expand Down
15 changes: 15 additions & 0 deletions plone/app/blocks/tests/test_utils.py
@@ -1,5 +1,7 @@
# -*- coding: utf-8 -*-
from plone.app.blocks.testing import BLOCKS_FUNCTIONAL_TESTING
from plone.app.blocks.utils import resolve
from plone.app.blocks.utils import resolveResource

import unittest

Expand Down Expand Up @@ -32,3 +34,16 @@ def test_resolve_utf8_bytestring(self):
</html>""".encode('utf-8')
text = resolve('', content_layout).xpath('//h1')[0].text
self.assertEqual(u'Ä', text)


class TestUtilsFunctional(unittest.TestCase):

layer = BLOCKS_FUNCTIONAL_TESTING

def test_resolve_resource(self):
layout = resolveResource('/++sitelayout++testlayout1/site.html')
self.assertIn(u'Layout panel 1', layout)

def test_resolve_resource_with_query(self):
layout = resolveResource('/++sitelayout++testlayout1/site.html?ajax_load=1')
self.assertIn(u'Layout panel 1', layout)
4 changes: 3 additions & 1 deletion plone/app/blocks/utils.py
Expand Up @@ -23,6 +23,7 @@

import logging
import urllib
import urlparse
import zope.deferredimport


Expand Down Expand Up @@ -97,7 +98,8 @@ def resolveResource(url):
url = urllib.unquote(url) # subrequest does not support quoted paths
if url.count('++') == 2:
# it is a resource that can be resolved without a subrequest
_, resource_type, path = url.split('++')
scheme, netloc, path, params, query, fragment = urlparse.urlparse(url)
_, resource_type, path = path.split('++')
resource_name, _, path = path.partition('/')
directory = queryResourceDirectory(resource_type, resource_name)
if isinstance(path, unicode):
Expand Down

0 comments on commit 543a8fc

Please sign in to comment.