1414# BASIS, AND THERE IS NO OBLIGATION WHATSOEVER TO PROVIDE MAINTENANCE,
1515# SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS.
1616#
17- # $Id: ZRoundup.py,v 1.6 2002-06-12 00:59:44 dman13 Exp $
17+ # $Id: ZRoundup.py,v 1.7 2002-06-14 01:25:46 dman13 Exp $
1818#
1919''' ZRoundup module - exposes the roundup web interface to Zope
2020
3232QUERY_STRING. Zope interprets the ':' as a special character, and the special
3333args are lost to it.
3434'''
35+
36+ import urlparse
37+
3538from Globals import InitializeClass , HTMLFile
3639from OFS .SimpleItem import Item
3740from OFS .PropertyManager import PropertyManager
@@ -125,9 +128,8 @@ def _opendb(self):
125128 env = self .REQUEST .environ
126129
127130 # figure out the path components to set
128- import urlparse
129- path = urlparse .urlparse ( self .absolute_url () )[2 ]
130- path_components = path .split ( '/' )
131+ url = urlparse .urlparse ( self .absolute_url () )
132+ path_components = url [2 ].split ( '/' )
131133
132134 # special case when roundup is '/' in this virtual host,
133135 if path == "/" :
@@ -138,7 +140,6 @@ def _opendb(self):
138140 env ['SCRIPT_NAME' ] = '/' .join ( path_components [:- 1 ] )
139141 # the last element is the name
140142 env ['INSTANCE_NAME' ] = path_components [- 1 ]
141- del path_components , path
142143
143144 if env ['REQUEST_METHOD' ] == 'GET' :
144145 # force roundup to re-parse the request because Zope fiddles
@@ -148,10 +149,26 @@ def _opendb(self):
148149 form = FormWrapper (self .REQUEST .form )
149150 return instance .Client (instance , request , env , form )
150151
152+
151153 security .declareProtected ('View' , 'index_html' )
152154 def index_html (self ):
153155 '''Alias index_html to roundup's index
154156 '''
157+
158+ # Redirect misdirected requests -- bugs 558867 , 565992
159+
160+ # PATH_INFO, as defined by the CGI spec, has the *real* request path
161+ orig_path = self .REQUEST .environ [ 'PATH_INFO' ]
162+ if orig_path [- 1 ] != '/' :
163+ url = urlparse .urlparse ( self .absolute_url () )
164+ url = list ( url ) # make mutable
165+ url [2 ] = url [2 ]+ '/' # patch
166+ url = urlparse .urlunparse ( url ) # reassemble
167+ RESPONSE = self .REQUEST .RESPONSE
168+ RESPONSE .setStatus ( "MovedPermanently" ) # 301
169+ RESPONSE .setHeader ( "Location" , url )
170+ return RESPONSE
171+
155172 client = self ._opendb ()
156173 # fake the path that roundup should use
157174 client .split_path = ['index' ]
@@ -184,6 +201,9 @@ def __getitem__(self, item):
184201
185202#
186203# $Log: not supported by cvs2svn $
204+ # Revision 1.6 2002/06/12 00:59:44 dman13
205+ # Fixed the logic for determing the cookie path. (Closes #562130.)
206+ #
187207# Revision 1.5 2002/05/14 23:36:25 richard
188208# . fixed SCRIPT_NAME in ZRoundup for instances not at top level of Zope
189209# (thanks dman)
0 commit comments