From e7bf1e1997af62da902767bc8fc6949d06793feb Mon Sep 17 00:00:00 2001 From: richard Date: Wed, 22 May 2002 04:12:05 +0000 Subject: [PATCH] . applied patch #558876 ] cgi client customization ... with significant additions and modifications ;) - extended handling of ML assignedto to all places it's handled - added more NotFound info git-svn-id: http://svn.roundup-tracker.org/svnroot/roundup/trunk@749 57a73879-2fb5-44c3-a270-3262357dd7e2 --- CHANGES.txt | 1 + roundup/cgi_client.py | 48 ++++++++++++++++++++++++++++--------------- roundup/hyperdb.py | 13 ++++++++++-- roundup/mailgw.py | 25 ++++++++++++++-------- 4 files changed, 60 insertions(+), 27 deletions(-) diff --git a/CHANGES.txt b/CHANGES.txt index 093b56f..5e3252c 100644 --- a/CHANGES.txt +++ b/CHANGES.txt @@ -29,6 +29,7 @@ Feature: on messages that create issues and followup messages. . reverting to dates for intervals > 2 months sucks . changed the default message list in issues to display the message body + . applied patch #558876 ] cgi client customization Fixed: . stop sending blank (whitespace-only) notes diff --git a/roundup/cgi_client.py b/roundup/cgi_client.py index ec13b47..9435c08 100644 --- a/roundup/cgi_client.py +++ b/roundup/cgi_client.py @@ -15,7 +15,7 @@ # BASIS, AND THERE IS NO OBLIGATION WHATSOEVER TO PROVIDE MAINTENANCE, # SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS. # -# $Id: cgi_client.py,v 1.121 2002-05-21 06:08:10 richard Exp $ +# $Id: cgi_client.py,v 1.122 2002-05-22 04:12:05 richard Exp $ __doc__ = """ WWW request handler (also used in the stand-alone server). @@ -167,8 +167,8 @@ function help_window(helpurl, width, height) { # skip if we need to fill in the logged-in user id there's # no user logged in if (spec['FILTERSPEC'].has_key('assignedto') and - spec['FILTERSPEC']['assignedto'] is None and - userid is None): + spec['FILTERSPEC']['assignedto'] in ('CURRENT USER', + None) and userid is None): continue links.append(self.make_index_link(name)) else: @@ -581,21 +581,32 @@ function help_window(helpurl, width, height) { def _add_assignedto_to_nosy(self, props): ''' add the assignedto value from the props to the nosy list ''' - if not props.has_key('assignedto'): + # get the properties definition and make some checks + cl = self.db.classes[self.classname] + propdef = cl.getprops() + if not propdef.has_key('assignedto') or not propdef.has_key('nosy'): + return + + # get the assignedto(s) + if isinstance(propdef['assignedto'], hyperdb.Link): + assignedto_ids = [props['assignedto']] + elif isinstance(propdef['assignedto'], hyperdb.Multilink): + assignedto_ids = props['assignedto'] + else: return - assignedto_id = props['assignedto'] + + # ok, now get the nosy list value if not props.has_key('nosy'): # load current nosy if self.nodeid: - cl = self.db.classes[self.classname] - l = cl.get(self.nodeid, 'nosy') - if assignedto_id in l: - return - props['nosy'] = l + props['nosy'] = cl.get(self.nodeid, 'nosy') else: props['nosy'] = [] - if assignedto_id not in props['nosy']: - props['nosy'].append(assignedto_id) + + # and update for assignedto id(s) + for assignedto_id in assignedto_ids: + if assignedto_id not in props['nosy']: + props['nosy'].append(assignedto_id) def _changenode(self, props): ''' change the node based on the contents of the form @@ -1256,15 +1267,15 @@ function help_window(helpurl, width, height) { try: cl = self.db.classes[self.classname] except KeyError: - raise NotFound + raise NotFound, self.classname try: cl.get(self.nodeid, 'id') except IndexError: - raise NotFound + raise NotFound, self.nodeid try: func = getattr(self, 'show%s'%self.classname) except AttributeError: - raise NotFound + raise NotFound, 'show%s'%self.classname func() return @@ -1275,7 +1286,7 @@ function help_window(helpurl, width, height) { try: func = getattr(self, 'new%s'%self.classname) except AttributeError: - raise NotFound + raise NotFound, 'new%s'%self.classname func() return @@ -1284,7 +1295,7 @@ function help_window(helpurl, width, height) { try: self.db.getclass(self.classname) except KeyError: - raise NotFound + raise NotFound, self.classname self.list() @@ -1384,6 +1395,9 @@ def parsePropsFromForm(db, cl, form, nodeid=0): # # $Log: not supported by cvs2svn $ +# Revision 1.121 2002/05/21 06:08:10 richard +# Handle migration +# # Revision 1.120 2002/05/21 06:05:53 richard # . #551483 ] assignedto in Client.make_index_link # diff --git a/roundup/hyperdb.py b/roundup/hyperdb.py index 5761e1d..bf532d2 100644 --- a/roundup/hyperdb.py +++ b/roundup/hyperdb.py @@ -15,7 +15,7 @@ # BASIS, AND THERE IS NO OBLIGATION WHATSOEVER TO PROVIDE MAINTENANCE, # SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS. # -# $Id: hyperdb.py,v 1.64 2002-05-15 06:21:21 richard Exp $ +# $Id: hyperdb.py,v 1.65 2002-05-22 04:12:05 richard Exp $ __doc__ = """ Hyperdatabase implementation, especially field types. @@ -608,7 +608,8 @@ class Class: for entry in value: # if it isn't a number, it's a key if type(entry) != type(''): - raise ValueError, 'link value must be String' + raise ValueError, 'new property "%s" link value ' \ + 'must be a string'%key if not num_re.match(entry): try: entry = self.db.classes[link_class].lookup(entry) @@ -1145,6 +1146,14 @@ def Choice(name, db, *options): # # $Log: not supported by cvs2svn $ +# Revision 1.64 2002/05/15 06:21:21 richard +# . node caching now works, and gives a small boost in performance +# +# As a part of this, I cleaned up the DEBUG output and implemented TRACE +# output (HYPERDBTRACE='file to trace to') with checkpoints at the start of +# CGI requests. Run roundup with python -O to skip all the DEBUG/TRACE stuff +# (using if __debug__ which is compiled out with -O) +# # Revision 1.63 2002/04/15 23:25:15 richard # . node ids are now generated from a lockable store - no more race conditions # diff --git a/roundup/mailgw.py b/roundup/mailgw.py index a114a58..4c99afb 100644 --- a/roundup/mailgw.py +++ b/roundup/mailgw.py @@ -73,7 +73,7 @@ are calling the create() method to create a new node). If an auditor raises an exception, the original message is bounced back to the sender with the explanatory message given in the exception. -$Id: mailgw.py,v 1.72 2002-05-22 01:24:51 richard Exp $ +$Id: mailgw.py,v 1.73 2002-05-22 04:12:05 richard Exp $ ''' @@ -654,7 +654,7 @@ not find a text/plain part to use. current = {} for nid in cl.get(nodeid, 'nosy'): current[nid] = 1 - self.updateNosy(props, author, recipients, current) + self.updateNosy(cl, props, author, recipients, current) # create the message message_id = self.db.msg.create(author=author, @@ -711,7 +711,7 @@ There was a problem with the message you sent: props['messages'] = [message_id] # set up (clean) the nosy list - self.updateNosy(props, author, recipients) + self.updateNosy(cl, props, author, recipients) # and attempt to create the new node try: @@ -727,7 +727,7 @@ There was a problem with the message you sent: return nodeid - def updateNosy(self, props, author, recipients, current=None): + def updateNosy(self, cl, props, author, recipients, current=None): '''Determine what the nosy list should be given: props: properties specified on the subject line of the message @@ -761,11 +761,16 @@ There was a problem with the message you sent: if not current.has_key(recipient): current[recipient] = 1 - # add assignedto to the nosy list + # add assignedto(s) to the nosy list if props.has_key('assignedto'): - assignedto = props['assignedto'] - if not current.has_key(assignedto): - current[assignedto] = 1 + propdef = cl.getprops() + if isinstance(propdef['assignedto'], hyperdb.Link): + assignedto_ids = [props['assignedto']] + elif isinstance(propdef['assignedto'], hyperdb.Multilink): + assignedto_ids = props['assignedto'] + for assignedto_id in assignedto_ids: + if not current.has_key(assignedto_id): + current[assignedto_id] = 1 props['nosy'] = current.keys() @@ -838,6 +843,10 @@ def parseContent(content, keep_citations, keep_body, # # $Log: not supported by cvs2svn $ +# Revision 1.72 2002/05/22 01:24:51 richard +# Added note to MIGRATION about new config vars. Also made us more resilient +# for upgraders. Reinstated list header style (oops) +# # Revision 1.71 2002/05/08 02:40:55 richard # grr # -- 2.30.2