changeset 736:b0d887310f7a

applied patch [SF#558876] cgi client customization ... with significant additions and modifications ;) - extended handling of ML assignedto to all places it's handled - added more NotFound info
author Richard Jones <richard@users.sourceforge.net>
date Wed, 22 May 2002 04:12:05 +0000
parents 1af6aa4e1023
children 3a653d485bbc
files CHANGES.txt roundup/cgi_client.py roundup/hyperdb.py roundup/mailgw.py
diffstat 4 files changed, 60 insertions(+), 27 deletions(-) [+]
line wrap: on
line diff
--- a/CHANGES.txt	Wed May 22 01:27:30 2002 +0000
+++ b/CHANGES.txt	Wed May 22 04:12:05 2002 +0000
@@ -29,6 +29,7 @@
    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
--- a/roundup/cgi_client.py	Wed May 22 01:27:30 2002 +0000
+++ b/roundup/cgi_client.py	Wed May 22 04:12:05 2002 +0000
@@ -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 @@
                 # 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 @@
     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
-        assignedto_id = props['assignedto']
+
+        # 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
+
+        # 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 @@
             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 @@
             try:
                 func = getattr(self, 'new%s'%self.classname)
             except AttributeError:
-                raise NotFound
+                raise NotFound, 'new%s'%self.classname
             func()
             return
 
@@ -1284,7 +1295,7 @@
         try:
             self.db.getclass(self.classname)
         except KeyError:
-            raise NotFound
+            raise NotFound, self.classname
         self.list()
 
 
@@ -1384,6 +1395,9 @@
 
 #
 # $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
 #
--- a/roundup/hyperdb.py	Wed May 22 01:27:30 2002 +0000
+++ b/roundup/hyperdb.py	Wed May 22 04:12:05 2002 +0000
@@ -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 @@
                 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 @@
 
 #
 # $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
 #
--- a/roundup/mailgw.py	Wed May 22 01:27:30 2002 +0000
+++ b/roundup/mailgw.py	Wed May 22 04:12:05 2002 +0000
@@ -73,7 +73,7 @@
 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 @@
             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 @@
             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 @@
 
         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 @@
                 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 @@
 
 #
 # $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
 #

Roundup Issue Tracker: http://roundup-tracker.org/