Back to index

plone3  3.1.7
accessRule.py
Go to the documentation of this file.
00001 # This Access Rule is used by installers so that when you install
00002 # Plone straight out of the box, port 80 will show up as the Plone site.
00003 #
00004 # If you are running mulitple sites then you probably won't want to use
00005 # this instead I'd recommend using VirtualHostMonster and a Proxy server
00006 # that can do rewriting such as Apache or Squid (see the Zope or Plone books
00007 # for more information). To remove this access the root ZMI and 
00008 # select 'Set Access Rule' to disable the access rule
00009 # (yes that is a little odd).
00010 #
00011 # If you are turning this off, also go into your Plone site and remove the
00012 # SiteRoot object. It should be benign with this access rule turned off, but
00013 # you don't need it any more.
00014 #
00015 # The installer sets up a default Plone site for you, called Plone (this
00016 # is assigned to siteObj variable). To allow you to get to the root this access
00017 # rule will accept an environment variable called HTTP_MANAGE to point to the
00018 # value of the manager port. This value is normally 8080 and is set by the 
00019 # zope.conf file.
00020 #
00021 # The Plone installer adds this in as an External Method pointing to
00022 # the accessRule function, below. If a request comes in and its not 
00023 # the HTTP_MANAGE port then its going to append Plone into the path and voila
00024 # you see your Plone site correctly.
00025 # 
00026 # This will work with FTP, WebDAV and all other protocols.
00027 
00028 import os
00029 
00030 HTTP_MANAGE = os.environ.get('HTTP_MANAGE', '')
00031 siteObj = 'Plone'
00032 
00033 def accessRule(self, *args):
00034     if self.REQUEST.get('SERVER_PORT', '') != HTTP_MANAGE and self.REQUEST['URL'].find(siteObj) < 0:
00035         self.REQUEST['TraversalRequestNameStack'].append(siteObj)
00036         self.REQUEST.set('SiteRootPATH', '/')
00037         # a useful little addition to the HTTP headers to allow proxies
00038         # and other tools to tell that this access rule has been activated
00039         # the fact that this rule gets run confuses a lot of people and this may help
00040         self.REQUEST.RESPONSE.addHeader('X-Access-Rule', 'accessRule.py')