Skip to content

Commit

Permalink
Merge pull request #34 from plone/rewritten_portal_name_1.5.x_pr
Browse files Browse the repository at this point in the history
Make findObject work if the webserver rewrites the portal name
  • Loading branch information
pbauer committed Jan 22, 2016
2 parents 1c359f6 + 16639dd commit 564b676
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 2 deletions.
3 changes: 2 additions & 1 deletion CHANGES.rst
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,8 @@ New:
Fixes:

- *add item here*

- make handler.findObject() work when the webserver rewrites the portal name
[tschorr]

1.5.7 (2015-11-17)
------------------
Expand Down
2 changes: 1 addition & 1 deletion plone/app/linkintegrity/handlers.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ def findObject(base, path):
if path.startswith('/'):
# Make an absolute path relative to the portal root
obj = getToolByName(base, 'portal_url').getPortalObject()
portal_path = '/'.join(obj.getPhysicalPath()) + '/'
portal_path = obj.absolute_url_path() + '/'
if path.startswith(portal_path):
path = path[len(portal_path):]
else:
Expand Down
11 changes: 11 additions & 0 deletions plone/app/linkintegrity/tests/test_handlers.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,3 +23,14 @@ def test_relative_to_portal_root_2(self):
obj, components = findObject(self.portal.doc1, '/doc2')
self.assertEqual(obj.absolute_url_path(), '/plone/doc2')
self.assertEqual(components, '')

def test_webserver_rewrites_portal_name(self):
# test the case where a webserver rewrites the portal name, e.g. for Apache:
# RewriteRule ^/wssitename(.*)$ http://localhost:8080/VirtualHostBase/http/my.domain.com:80/plonesitename/VirtualHostRoot/_vh_wssitename$1
self.portal.REQUEST.other['VirtualRootPhysicalPath'] = ('', 'plone')
self.portal.REQUEST._script = ['plone_foo']
obj, components = findObject(self.portal.doc1, '/plone_foo/doc2')
self.assertEqual(obj.absolute_url_path(), '/plone_foo/doc2')
self.assertEqual(obj.getPhysicalPath(), ('','plone', 'doc2'))
self.assertEqual(components, '')

0 comments on commit 564b676

Please sign in to comment.