Skip to content

Commit 8bd7149

Browse files
author
Derrick Hudson
committed
Fixed [SF#558867] by redirecting /instance requests to /instance/
1 parent c036413 commit 8bd7149

File tree

2 files changed

+26
-5
lines changed

2 files changed

+26
-5
lines changed

CHANGES.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ Feature:
4040
- also changed cgi client since it was duplicating the functionality
4141

4242
Fixed:
43+
. #558867 ] ZRoundup redirect /instance requests to /instance/
4344
. #562130 ] cookie path generated from ZRoundup was wrong in some situations
4445
. stop sending blank (whitespace-only) notes
4546
. cleanup of serialisation for database storage

frontends/ZRoundup/ZRoundup.py

Lines changed: 25 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
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
@@ -32,6 +32,9 @@
3232
QUERY_STRING. Zope interprets the ':' as a special character, and the special
3333
args are lost to it.
3434
'''
35+
36+
import urlparse
37+
3538
from Globals import InitializeClass, HTMLFile
3639
from OFS.SimpleItem import Item
3740
from 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

Comments
 (0)