Commit 1c5e7ba1 authored by Tres Seaver's avatar Tres Seaver

Formatting.

parent fbf16d96
...@@ -19,12 +19,12 @@ from Products.SiteAccess.AccessRule import _swallow ...@@ -19,12 +19,12 @@ from Products.SiteAccess.AccessRule import _swallow
SUPPRESS_SITEROOT = os.environ.has_key('SUPPRESS_SITEROOT') SUPPRESS_SITEROOT = os.environ.has_key('SUPPRESS_SITEROOT')
class Traverser(Persistent, Item): class Traverser(Persistent, Item):
"""Class for overriding container's __before_traverse__ """ Class for overriding container's __before_traverse__
Containers are expected to have at most one instance of any particular Containers are expected to have at most one instance of any particular
subclass, with Id equal to the meta_type of the subclass.""" subclass, with Id equal to the meta_type of the subclass.
"""
meta_type='Traverser' meta_type = 'Traverser'
priority = 100 priority = 100
__ac_permissions__=() __ac_permissions__=()
...@@ -66,22 +66,24 @@ class Traverser(Persistent, Item): ...@@ -66,22 +66,24 @@ class Traverser(Persistent, Item):
% escape(self.meta_type)) % escape(self.meta_type))
class SiteRoot(Traverser, Implicit): class SiteRoot(Traverser, Implicit):
"""SiteAccess.SiteRoot object """ SiteAccess.SiteRoot object
A SiteRoot causes traversal of its container to replace the part A SiteRoot causes traversal of its container to replace the part
of the Request path traversed so far with the request's SiteRootURL.""" of the Request path traversed so far with the request's SiteRootURL.
"""
id = meta_type = 'SiteRoot' id = meta_type = 'SiteRoot'
title = '' title = ''
priority = 50 priority = 50
manage_options=({'label':'Edit', 'action':'manage_main', 'help': ('SiteAccess', 'SiteRoot_Edit.stx')},) manage_options=({'label':'Edit',
'action':'manage_main',
'help': ('SiteAccess', 'SiteRoot_Edit.stx'),
},)
manage = manage_main = DTMLFile('www/SiteRootEdit', globals()) manage = manage_main = DTMLFile('www/SiteRootEdit', globals())
manage_main._setName('manage_main') manage_main._setName('manage_main')
def __init__(self, title, base, path): def __init__(self, title, base, path):
'''Title'''
self.title = title.strip() self.title = title.strip()
self.base = base = base.strip() self.base = base = base.strip()
self.path = path = path.strip() self.path = path = path.strip()
...@@ -95,7 +97,8 @@ class SiteRoot(Traverser, Implicit): ...@@ -95,7 +97,8 @@ class SiteRoot(Traverser, Implicit):
except: pass except: pass
def manage_edit(self, title, base, path, REQUEST=None): def manage_edit(self, title, base, path, REQUEST=None):
'''Set the title, base, and path''' """ Set the title, base, and path.
"""
self.__init__(title, base, path) self.__init__(title, base, path)
if REQUEST: if REQUEST:
return MessageDialog(title='SiteRoot changed.', return MessageDialog(title='SiteRoot changed.',
...@@ -103,8 +106,10 @@ class SiteRoot(Traverser, Implicit): ...@@ -103,8 +106,10 @@ class SiteRoot(Traverser, Implicit):
action='%s/manage_main' % REQUEST['URL1']) action='%s/manage_main' % REQUEST['URL1'])
def __call__(self, client, request, response=None): def __call__(self, client, request, response=None):
'''Traversing''' """ Traversing.
if SUPPRESS_SITEROOT: return """
if SUPPRESS_SITEROOT:
return
if '_SUPPRESS_SITEROOT' in _swallow(request, '_SUPPRESS'): if '_SUPPRESS_SITEROOT' in _swallow(request, '_SUPPRESS'):
request.setVirtualRoot(request.steps) request.setVirtualRoot(request.steps)
return return
...@@ -118,22 +123,26 @@ class SiteRoot(Traverser, Implicit): ...@@ -118,22 +123,26 @@ class SiteRoot(Traverser, Implicit):
if srd[i] is None: if srd[i] is None:
srd[i] = request.environ.get(srp, None) srd[i] = request.environ.get(srp, None)
if srd[0] is not None: if srd[0] is not None:
request['ACTUAL_URL'] = request['ACTUAL_URL'].replace(request['SERVER_URL'], srd[0]) request['ACTUAL_URL'] = request['ACTUAL_URL'].replace(
request['SERVER_URL'], srd[0])
request['SERVER_URL'] = srd[0] request['SERVER_URL'] = srd[0]
request._resetURLS() request._resetURLS()
if srd[1] is not None: if srd[1] is not None:
old = request['URL'] old = request['URL']
request.setVirtualRoot(srd[1]) request.setVirtualRoot(srd[1])
request['ACTUAL_URL'] = request['ACTUAL_URL'].replace(old, request['URL']) request['ACTUAL_URL'] = request['ACTUAL_URL'].replace(
old, request['URL'])
def get_size(self): def get_size(self):
'''Make FTP happy''' """ Make FTP happy
"""
return 0 return 0
def manage_addSiteRoot(self, title='', base='', path='', REQUEST=None, def manage_addSiteRoot(self, title='', base='', path='', REQUEST=None,
**ignored): **ignored):
""" """ """ Add a SiteRoot to a container.
sr=SiteRoot(title, base, path) """
sr = SiteRoot(title, base, path)
if REQUEST: if REQUEST:
return sr.manage_addToContainer(self.this(), return sr.manage_addToContainer(self.this(),
'%s/manage_main' % REQUEST['URL1']) '%s/manage_main' % REQUEST['URL1'])
......
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