Skip to content

Commit 55835d1

Browse files
author
Richard Jones
committed
Made error on create consistent with edit when user enters invalid data...
for Multilink and Link form fields [SF#904072]
1 parent cdb45e8 commit 55835d1

File tree

2 files changed

+17
-6
lines changed

2 files changed

+17
-6
lines changed

CHANGES.txt

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,12 @@
11
This file contains the changes to the Roundup system over time. The entries
22
are given with the most recent entry first.
33

4+
2004-02-25 0.6.7
5+
Fixed:
6+
- made error on create consistent with edit when user enters invalid data
7+
for Multilink and Link form fields (sf bug 904072)
8+
9+
410
2004-02-25 0.6.6
511
Fixed:
612
- don't insert spaces into designators, it just confuses users (sf bug

roundup/cgi/templating.py

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -247,7 +247,10 @@ def classes(self):
247247
l.sort()
248248
return [HTMLClass(self._client, cn) for cn in l]
249249

250-
def lookupIds(db, prop, ids, num_re=re.compile('-?\d+')):
250+
def lookupIds(db, prop, ids, fail_ok=False, num_re=re.compile('-?\d+')):
251+
''' "fail_ok" should be specified if we wish to pass through bad values
252+
(most likely form values that we wish to represent back to the user)
253+
'''
251254
cl = db.getclass(prop.classname)
252255
l = []
253256
for entry in ids:
@@ -256,9 +259,10 @@ def lookupIds(db, prop, ids, num_re=re.compile('-?\d+')):
256259
else:
257260
try:
258261
l.append(cl.lookup(entry))
259-
except KeyError:
260-
# ignore invalid keys
261-
pass
262+
except (TypeError, KeyError):
263+
if fail_ok:
264+
# pass through the bad value
265+
l.append(entry)
262266
return l
263267

264268
class HTMLPermissions:
@@ -316,11 +320,12 @@ def __getitem__(self, item):
316320
if form.has_key(item):
317321
if isinstance(prop, hyperdb.Multilink):
318322
value = lookupIds(self._db, prop,
319-
handleListCGIValue(form[item]))
323+
handleListCGIValue(form[item]), fail_ok=True)
320324
elif isinstance(prop, hyperdb.Link):
321325
value = form[item].value.strip()
322326
if value:
323-
value = lookupIds(self._db, prop, [value])[0]
327+
value = lookupIds(self._db, prop, [value],
328+
fail_ok=True)[0]
324329
else:
325330
value = None
326331
else:

0 commit comments

Comments
 (0)