Commit 278d500b authored by Jérome Perrin's avatar Jérome Perrin

delete HTTPRequest patch, it's now integrated in WebSite.py



git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@8849 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent 06de9e76
......@@ -42,7 +42,6 @@ from AccessControl.User import emergency_user
from AccessControl.SecurityManagement import newSecurityManager,\
setSecurityManager
from ZPublisher import BeforeTraverse
from Products.ERP5Type.patches.HTTPRequest import website_key
from zLOG import LOG
......
##############################################################################
#
# Copyright (c) 2001 Zope Corporation and Contributors. All Rights Reserved.
# Copyright (c) 2002,2005 Nexedi SARL and Contributors. All Rights Reserved.
#
# This software is subject to the provisions of the Zope Public License,
# Version 2.0 (ZPL). A copy of the ZPL should accompany this distribution.
# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
# FOR A PARTICULAR PURPOSE
#
##############################################################################
# This patch is used by WebSite to rewrite URLs in such way
# that once a user gets into a Web Site object, all
# documents referenced by the web site are accessed
# through the web site rather than directly.
website_key = 'web_site_value'
from ZPublisher.HTTPRequest import HTTPRequest
def HTTPRequest_physicalPathToVirtualPath(self, path):
"""
Remove the path to the VirtualRoot from a physical path
and add the path to the WebSite is any
"""
if type(path) is type(''):
path = path.split( '/')
website_path = self.get(website_key, None)
if website_path:
website_path = tuple(website_path) # Make sure all path are tuples
path = tuple(path) # Make sure all path are tuples
# Search for the common part index
# XXX more testing should be added to check
# if the URL is the kind of URL which is a Web Site
# XXX more support required for ignore_layout
i = 0
path_len = len(path)
for name in website_path:
if i >= path_len: break
if path[i] == name:
common_index = i
i += 1
# Insert the web site path after the common part of the path
if path_len > common_index + 1:
path = website_path + path[common_index + 1:]
rpp = self.other.get('VirtualRootPhysicalPath', ('',))
i = 0
for name in rpp[:len(path)]:
if path[i] == name:
i = i + 1
else:
break
return path[i:]
HTTPRequest.physicalPathToVirtualPath = HTTPRequest_physicalPathToVirtualPath
\ No newline at end of file
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment