How To Fix Strange Behavior in accessRule.py
The original accessRule.py delivered with Plone in INSTANCE/Products/CMFPlone/Extensions looks like this :
import os
HTTP_MANAGE = os.environ.get('HTTP_MANAGE', '')
siteObj = 'Plone'
def accessRule(self, *args):
if self.REQUEST.get('SERVER_PORT', '') != HTTP_MANAGE and self.REQUEST['URL'].find(siteObj) < 0:
self.REQUEST['TraversalRequestNameStack'].append(siteObj)
self.REQUEST.set('SiteRootPATH', '/')
Unfortunately, it occasionally introduces extra /Plone nodes in the URL, so we make a copy in the INSTANCE/Extensions directory and make the following simple change to correct the problem :
import os
HTTP_MANAGE = os.environ.get('HTTP_MANAGE', '')
siteObj = 'Plone'
def accessRule(self, *args):
if self.REQUEST.get('SERVER_PORT', '') != HTTP_MANAGE and \
self.REQUEST['TraversalRequestNameStack'].count(siteObj) < 1 and \
self.REQUEST['URL'].find(siteObj) < 0:
self.REQUEST['TraversalRequestNameStack'].append(siteObj)
self.REQUEST.set('SiteRootPATH', '/')
See How To Build Plone From Source for information on how to activate the access rule script.
import os
HTTP_MANAGE = os.environ.get('HTTP_MANAGE', '')
siteObj = 'Plone'
def accessRule(self, *args):
if self.REQUEST.get('SERVER_PORT', '') != HTTP_MANAGE and self.REQUEST['URL'].find(siteObj) < 0:
self.REQUEST['TraversalRequestNameStack'].append(siteObj)
self.REQUEST.set('SiteRootPATH', '/')
Unfortunately, it occasionally introduces extra /Plone nodes in the URL, so we make a copy in the INSTANCE/Extensions directory and make the following simple change to correct the problem :
import os
HTTP_MANAGE = os.environ.get('HTTP_MANAGE', '')
siteObj = 'Plone'
def accessRule(self, *args):
if self.REQUEST.get('SERVER_PORT', '') != HTTP_MANAGE and \
self.REQUEST['TraversalRequestNameStack'].count(siteObj) < 1 and \
self.REQUEST['URL'].find(siteObj) < 0:
self.REQUEST['TraversalRequestNameStack'].append(siteObj)
self.REQUEST.set('SiteRootPATH', '/')
See How To Build Plone From Source for information on how to activate the access rule script.