Skip to content

Commit 556d115

Browse files
author
Richard Jones
committed
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
1 parent b3575b2 commit 556d115

File tree

4 files changed

+60
-27
lines changed

4 files changed

+60
-27
lines changed

CHANGES.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ Feature:
2929
on messages that create issues and followup messages.
3030
. reverting to dates for intervals > 2 months sucks
3131
. changed the default message list in issues to display the message body
32+
. applied patch #558876 ] cgi client customization
3233

3334
Fixed:
3435
. stop sending blank (whitespace-only) notes

roundup/cgi_client.py

Lines changed: 31 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
# BASIS, AND THERE IS NO OBLIGATION WHATSOEVER TO PROVIDE MAINTENANCE,
1616
# SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS.
1717
#
18-
# $Id: cgi_client.py,v 1.121 2002-05-21 06:08:10 richard Exp $
18+
# $Id: cgi_client.py,v 1.122 2002-05-22 04:12:05 richard Exp $
1919

2020
__doc__ = """
2121
WWW request handler (also used in the stand-alone server).
@@ -167,8 +167,8 @@ def pagehead(self, title, message=None):
167167
# skip if we need to fill in the logged-in user id there's
168168
# no user logged in
169169
if (spec['FILTERSPEC'].has_key('assignedto') and
170-
spec['FILTERSPEC']['assignedto'] is None and
171-
userid is None):
170+
spec['FILTERSPEC']['assignedto'] in ('CURRENT USER',
171+
None) and userid is None):
172172
continue
173173
links.append(self.make_index_link(name))
174174
else:
@@ -581,21 +581,32 @@ def _add_author_to_nosy(self, props):
581581
def _add_assignedto_to_nosy(self, props):
582582
''' add the assignedto value from the props to the nosy list
583583
'''
584-
if not props.has_key('assignedto'):
584+
# get the properties definition and make some checks
585+
cl = self.db.classes[self.classname]
586+
propdef = cl.getprops()
587+
if not propdef.has_key('assignedto') or not propdef.has_key('nosy'):
588+
return
589+
590+
# get the assignedto(s)
591+
if isinstance(propdef['assignedto'], hyperdb.Link):
592+
assignedto_ids = [props['assignedto']]
593+
elif isinstance(propdef['assignedto'], hyperdb.Multilink):
594+
assignedto_ids = props['assignedto']
595+
else:
585596
return
586-
assignedto_id = props['assignedto']
597+
598+
# ok, now get the nosy list value
587599
if not props.has_key('nosy'):
588600
# load current nosy
589601
if self.nodeid:
590-
cl = self.db.classes[self.classname]
591-
l = cl.get(self.nodeid, 'nosy')
592-
if assignedto_id in l:
593-
return
594-
props['nosy'] = l
602+
props['nosy'] = cl.get(self.nodeid, 'nosy')
595603
else:
596604
props['nosy'] = []
597-
if assignedto_id not in props['nosy']:
598-
props['nosy'].append(assignedto_id)
605+
606+
# and update for assignedto id(s)
607+
for assignedto_id in assignedto_ids:
608+
if assignedto_id not in props['nosy']:
609+
props['nosy'].append(assignedto_id)
599610

600611
def _changenode(self, props):
601612
''' change the node based on the contents of the form
@@ -1256,15 +1267,15 @@ def do_action(self, action, dre=re.compile(r'([^\d]+)(\d+)'),
12561267
try:
12571268
cl = self.db.classes[self.classname]
12581269
except KeyError:
1259-
raise NotFound
1270+
raise NotFound, self.classname
12601271
try:
12611272
cl.get(self.nodeid, 'id')
12621273
except IndexError:
1263-
raise NotFound
1274+
raise NotFound, self.nodeid
12641275
try:
12651276
func = getattr(self, 'show%s'%self.classname)
12661277
except AttributeError:
1267-
raise NotFound
1278+
raise NotFound, 'show%s'%self.classname
12681279
func()
12691280
return
12701281

@@ -1275,7 +1286,7 @@ def do_action(self, action, dre=re.compile(r'([^\d]+)(\d+)'),
12751286
try:
12761287
func = getattr(self, 'new%s'%self.classname)
12771288
except AttributeError:
1278-
raise NotFound
1289+
raise NotFound, 'new%s'%self.classname
12791290
func()
12801291
return
12811292

@@ -1284,7 +1295,7 @@ def do_action(self, action, dre=re.compile(r'([^\d]+)(\d+)'),
12841295
try:
12851296
self.db.getclass(self.classname)
12861297
except KeyError:
1287-
raise NotFound
1298+
raise NotFound, self.classname
12881299
self.list()
12891300

12901301

@@ -1384,6 +1395,9 @@ def parsePropsFromForm(db, cl, form, nodeid=0):
13841395

13851396
#
13861397
# $Log: not supported by cvs2svn $
1398+
# Revision 1.121 2002/05/21 06:08:10 richard
1399+
# Handle migration
1400+
#
13871401
# Revision 1.120 2002/05/21 06:05:53 richard
13881402
# . #551483 ] assignedto in Client.make_index_link
13891403
#

roundup/hyperdb.py

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
# BASIS, AND THERE IS NO OBLIGATION WHATSOEVER TO PROVIDE MAINTENANCE,
1616
# SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS.
1717
#
18-
# $Id: hyperdb.py,v 1.64 2002-05-15 06:21:21 richard Exp $
18+
# $Id: hyperdb.py,v 1.65 2002-05-22 04:12:05 richard Exp $
1919

2020
__doc__ = """
2121
Hyperdatabase implementation, especially field types.
@@ -608,7 +608,8 @@ class or a KeyError is raised.
608608
for entry in value:
609609
# if it isn't a number, it's a key
610610
if type(entry) != type(''):
611-
raise ValueError, 'link value must be String'
611+
raise ValueError, 'new property "%s" link value ' \
612+
'must be a string'%key
612613
if not num_re.match(entry):
613614
try:
614615
entry = self.db.classes[link_class].lookup(entry)
@@ -1145,6 +1146,14 @@ def Choice(name, db, *options):
11451146

11461147
#
11471148
# $Log: not supported by cvs2svn $
1149+
# Revision 1.64 2002/05/15 06:21:21 richard
1150+
# . node caching now works, and gives a small boost in performance
1151+
#
1152+
# As a part of this, I cleaned up the DEBUG output and implemented TRACE
1153+
# output (HYPERDBTRACE='file to trace to') with checkpoints at the start of
1154+
# CGI requests. Run roundup with python -O to skip all the DEBUG/TRACE stuff
1155+
# (using if __debug__ which is compiled out with -O)
1156+
#
11481157
# Revision 1.63 2002/04/15 23:25:15 richard
11491158
# . node ids are now generated from a lockable store - no more race conditions
11501159
#

roundup/mailgw.py

Lines changed: 17 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ class node. Any parts of other types are each stored in separate files
7373
an exception, the original message is bounced back to the sender with the
7474
explanatory message given in the exception.
7575
76-
$Id: mailgw.py,v 1.72 2002-05-22 01:24:51 richard Exp $
76+
$Id: mailgw.py,v 1.73 2002-05-22 04:12:05 richard Exp $
7777
'''
7878

7979

@@ -654,7 +654,7 @@ def handle_message(self, message):
654654
current = {}
655655
for nid in cl.get(nodeid, 'nosy'):
656656
current[nid] = 1
657-
self.updateNosy(props, author, recipients, current)
657+
self.updateNosy(cl, props, author, recipients, current)
658658

659659
# create the message
660660
message_id = self.db.msg.create(author=author,
@@ -711,7 +711,7 @@ def handle_message(self, message):
711711
props['messages'] = [message_id]
712712

713713
# set up (clean) the nosy list
714-
self.updateNosy(props, author, recipients)
714+
self.updateNosy(cl, props, author, recipients)
715715

716716
# and attempt to create the new node
717717
try:
@@ -727,7 +727,7 @@ def handle_message(self, message):
727727

728728
return nodeid
729729

730-
def updateNosy(self, props, author, recipients, current=None):
730+
def updateNosy(self, cl, props, author, recipients, current=None):
731731
'''Determine what the nosy list should be given:
732732
733733
props: properties specified on the subject line of the message
@@ -761,11 +761,16 @@ def updateNosy(self, props, author, recipients, current=None):
761761
if not current.has_key(recipient):
762762
current[recipient] = 1
763763

764-
# add assignedto to the nosy list
764+
# add assignedto(s) to the nosy list
765765
if props.has_key('assignedto'):
766-
assignedto = props['assignedto']
767-
if not current.has_key(assignedto):
768-
current[assignedto] = 1
766+
propdef = cl.getprops()
767+
if isinstance(propdef['assignedto'], hyperdb.Link):
768+
assignedto_ids = [props['assignedto']]
769+
elif isinstance(propdef['assignedto'], hyperdb.Multilink):
770+
assignedto_ids = props['assignedto']
771+
for assignedto_id in assignedto_ids:
772+
if not current.has_key(assignedto_id):
773+
current[assignedto_id] = 1
769774

770775
props['nosy'] = current.keys()
771776

@@ -838,6 +843,10 @@ def parseContent(content, keep_citations, keep_body,
838843

839844
#
840845
# $Log: not supported by cvs2svn $
846+
# Revision 1.72 2002/05/22 01:24:51 richard
847+
# Added note to MIGRATION about new config vars. Also made us more resilient
848+
# for upgraders. Reinstated list header style (oops)
849+
#
841850
# Revision 1.71 2002/05/08 02:40:55 richard
842851
# grr
843852
#

0 commit comments

Comments
 (0)