X-Git-Url: https://git.tokkee.org/?a=blobdiff_plain;f=frontends%2FZRoundup%2FZRoundup.py;h=5b4077203cf5cdadaeaa910b26d467981000ab3d;hb=1d2361aba006cdd3fd144032a19de1d01467770e;hp=e1614a85059d401368e01f57ea8a96e24ef50d33;hpb=3c74332b0f4a6f0268eb9145c27fa5a21a33d67e;p=roundup.git diff --git a/frontends/ZRoundup/ZRoundup.py b/frontends/ZRoundup/ZRoundup.py index e1614a8..5b40772 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.9 2002-07-04 01:25:22 dman13 Exp $ +# $Id: ZRoundup.py,v 1.17 2003-11-12 01:00:58 richard Exp $ # ''' ZRoundup module - exposes the roundup web interface to Zope @@ -26,11 +26,6 @@ This means that the regular CGI interface does all authentication quite independently of Zope. The roundup code is kept in memory though, and it runs in the same server as all your other Zope stuff, so it does have _some_ advantages over regular CGI :) - -It also means that any requests which specify :filter, :columns or :sort -_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 @@ -38,14 +33,14 @@ import urlparse from Globals import InitializeClass, HTMLFile from OFS.SimpleItem import Item from OFS.PropertyManager import PropertyManager -from Acquisition import Implicit +from Acquisition import Explicit, Implicit from Persistence import Persistent from AccessControl import ClassSecurityInfo from AccessControl import ModuleSecurityInfo modulesecurity = ModuleSecurityInfo() import roundup.instance -from roundup import cgi_client +from roundup.cgi.client import NotFound modulesecurity.declareProtected('View management screens', 'manage_addZRoundupForm') @@ -119,8 +114,8 @@ class ZRoundup(Item, PropertyManager, Implicit, Persistent): icon = "misc_/ZRoundup/icon" - security.declarePrivate('_opendb') - def _opendb(self): + security.declarePrivate('roundup_opendb') + def roundup_opendb(self): '''Open the roundup instance database for a transaction. ''' instance = roundup.instance.open(self.instance_home) @@ -131,41 +126,27 @@ class ZRoundup(Item, PropertyManager, Implicit, Persistent): 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'] = '' + env['TRACKER_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: - # 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) + env['TRACKER_NAME'] = path_components[-1] + form = FormWrapper(self.REQUEST.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' ] + orig_path = self.REQUEST.environ['PATH_INFO'] if orig_path[-1] != '/' : url = urlparse.urlparse( self.absolute_url() ) url = list( url ) # make mutable @@ -176,7 +157,7 @@ class ZRoundup(Item, PropertyManager, Implicit, Persistent): RESPONSE.setHeader( "Location" , url ) return RESPONSE - client = self._opendb() + client = self.roundup_opendb() # fake the path that roundup should use client.split_path = ['index'] return client.main() @@ -184,55 +165,39 @@ class ZRoundup(Item, PropertyManager, Implicit, Persistent): def __getitem__(self, item): '''All other URL accesses are passed throuh to roundup ''' + return PathElement(self, item).__of__(self) + +class PathElement(Item, Implicit): + def __init__(self, zr, path): + self.zr = zr + self.path = path + + def __getitem__(self, item): + ''' Get a subitem. + ''' + return PathElement(self.zr, self.path + '/' + item).__of__(self) + + def index_html(self, REQUEST=None): + ''' Actually call through to roundup to handle the request. + ''' try: - client = self._opendb() + client = self.zr.roundup_opendb() # fake the path that roundup should use - client.split_path = [item] + client.path = self.path # and call roundup to do something client.main() return '' - except cgi_client.NotFound: - raise 'NotFound', self.REQUEST.URL + except NotFound: + raise 'NotFound', REQUEST.URL pass except: import traceback traceback.print_exc() # all other exceptions in roundup are valid raise - raise KeyError, item - InitializeClass(ZRoundup) modulesecurity.apply(globals()) -# -# $Log: not supported by cvs2svn $ -# 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 -# -# Revision 1.3 2001/12/12 23:55:00 richard -# Fixed some problems with user editing -# -# Revision 1.2 2001/12/12 23:33:58 richard -# added some implementation notes -# -# Revision 1.1 2001/12/12 23:27:13 richard -# Added a Zope frontend for roundup. -# -# -# # vim: set filetype=python ts=4 sw=4 et si