X-Git-Url: https://git.tokkee.org/?a=blobdiff_plain;f=frontends%2FZRoundup%2FZRoundup.py;h=0be45f38af4c7934432921d4c75ac0d2038b1691;hb=8a78211fbb92a36e8985e8e2e178f7b45ffd21d4;hp=5a40435e770355a9962455203733bb0938b932ea;hpb=5ef76a014e3d16005c541a4a40b5ca6c8ca94f9d;p=roundup.git diff --git a/frontends/ZRoundup/ZRoundup.py b/frontends/ZRoundup/ZRoundup.py index 5a40435..0be45f3 100644 --- a/frontends/ZRoundup/ZRoundup.py +++ b/frontends/ZRoundup/ZRoundup.py @@ -14,7 +14,7 @@ # BASIS, AND THERE IS NO OBLIGATION WHATSOEVER TO PROVIDE MAINTENANCE, # SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS. # -# $Id: ZRoundup.py,v 1.5 2002-05-14 23:36:25 richard Exp $ +# $Id: ZRoundup.py,v 1.10 2002-09-04 02:05:19 richard Exp $ # ''' ZRoundup module - exposes the roundup web interface to Zope @@ -32,6 +32,9 @@ _must_ be done using a GET, so that this interface can re-parse the QUERY_STRING. Zope interprets the ':' as a special character, and the special args are lost to it. ''' + +import urlparse + from Globals import InitializeClass, HTMLFile from OFS.SimpleItem import Item from OFS.PropertyManager import PropertyManager @@ -42,7 +45,7 @@ from AccessControl import ModuleSecurityInfo modulesecurity = ModuleSecurityInfo() import roundup.instance -from roundup import cgi_client +from roundup.cgi import NotFound modulesecurity.declareProtected('View management screens', 'manage_addZRoundupForm') @@ -123,20 +126,56 @@ class ZRoundup(Item, PropertyManager, Implicit, Persistent): instance = roundup.instance.open(self.instance_home) request = RequestWrapper(self.REQUEST['RESPONSE']) env = self.REQUEST.environ - env['SCRIPT_NAME'] = '/'.join(self.getPhysicalPath()[:-1]) - env['INSTANCE_NAME'] = self.id + + # figure out the path components to set + url = urlparse.urlparse( self.absolute_url() ) + path = url[2] + path_components = path.split( '/' ) + + # special case when roundup is '/' in this virtual host, + if path == "/" : + env['SCRIPT_NAME'] = "/" + env['INSTANCE_NAME'] = '' + else : + # all but the last element is the path + env['SCRIPT_NAME'] = '/'.join( path_components[:-1] ) + # the last element is the name + env['INSTANCE_NAME'] = path_components[-1] + if env['REQUEST_METHOD'] == 'GET': # force roundup to re-parse the request because Zope fiddles # with it and we lose all the :filter, :columns, etc goodness form = None else: - form = FormWrapper(self.REQUEST.form) + # For some reason, CRs are embeded in multiline notes. + # It doesn't occur with apache/roundup.cgi, though. + form = self.REQUEST.form + if form.has_key( '__note' ) : + form['__note'] = form['__note'].replace( '\r' , '' ) + form = FormWrapper(form) + return instance.Client(instance, request, env, form) + security.declareProtected('View', 'index_html') def index_html(self): '''Alias index_html to roundup's index ''' + + # Redirect misdirected requests -- bugs 558867 , 565992 + + # PATH_INFO, as defined by the CGI spec, has the *real* request path + orig_path = self.REQUEST.environ[ 'PATH_INFO' ] + if orig_path[-1] != '/' : + url = urlparse.urlparse( self.absolute_url() ) + url = list( url ) # make mutable + url[2] = url[2]+'/' # patch + url = urlparse.urlunparse( url ) # reassemble + RESPONSE = self.REQUEST.RESPONSE + RESPONSE.setStatus( "MovedPermanently" ) # 301 + RESPONSE.setHeader( "Location" , url ) + return RESPONSE + client = self._opendb() # fake the path that roundup should use client.split_path = ['index'] @@ -152,7 +191,7 @@ class ZRoundup(Item, PropertyManager, Implicit, Persistent): # and call roundup to do something client.main() return '' - except cgi_client.NotFound: + except NotFound: raise 'NotFound', self.REQUEST.URL pass except: @@ -169,6 +208,22 @@ modulesecurity.apply(globals()) # # $Log: not supported by cvs2svn $ +# Revision 1.9 2002/07/04 01:25:22 dman13 +# fixed #576086 (dumb copying mistake) +# +# Revision 1.8 2002/06/16 01:01:42 dman13 +# remove CR characters embedded in messages (ZRoundup) +# +# Revision 1.7 2002/06/14 01:25:46 dman13 +# Fixed bug #558867 by redirecting /instance requests to /instance/ +# +# Revision 1.6 2002/06/12 00:59:44 dman13 +# Fixed the logic for determing the cookie path. (Closes #562130.) +# +# Revision 1.5 2002/05/14 23:36:25 richard +# . fixed SCRIPT_NAME in ZRoundup for instances not at top level of Zope +# (thanks dman) +# # Revision 1.4 2002/01/10 03:38:16 richard # reformatting for 80 cols #