Skip to content

Commit a668ec2

Browse files
author
Richard Jones
committed
*** empty log message ***
1 parent b4e8462 commit a668ec2

File tree

1 file changed

+9
-22
lines changed

1 file changed

+9
-22
lines changed

roundup/cgi/templating.py

Lines changed: 9 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -287,7 +287,7 @@ def __getitem__(self, item):
287287
if form.has_key(item):
288288
if isinstance(prop, hyperdb.Multilink):
289289
value = lookupIds(self._db, prop,
290-
handleListCGIValue(None, form[item]))
290+
handleListCGIValue(form[item]))
291291
elif isinstance(prop, hyperdb.Link):
292292
value = form[item].value.strip()
293293
if value:
@@ -1174,30 +1174,17 @@ def sortfunc(a, b, linkcl=linkcl, sort_on=sort_on):
11741174
return cmp(linkcl.get(a, sort_on), linkcl.get(b, sort_on))
11751175
return sortfunc
11761176

1177-
def handleListCGIValue(klass, value, num_re=re.compile('\d+')):
1177+
def handleListCGIValue(value):
11781178
''' Value is either a single item or a list of items. Each item has a
11791179
.value that we're actually interested in.
11801180
'''
11811181
if isinstance(value, type([])):
1182-
l = [value.value for value in value]
1182+
return [value.value for value in value]
11831183
else:
11841184
value = value.value.strip()
11851185
if not value:
11861186
return []
1187-
l = value.split(',')
1188-
1189-
if klass is None:
1190-
return l
1191-
1192-
# otherwise, try to make sure the values are itemids of the given class
1193-
r = []
1194-
for itemid in l:
1195-
# make sure we're looking at an itemid
1196-
if not num_re.match(itemid):
1197-
itemid = self._klass.lookup(itemid)
1198-
else:
1199-
r.append(itemid)
1200-
return r
1187+
return value.split(',')
12011188

12021189
class ShowDict:
12031190
''' A convenience access to the :columns index parameters
@@ -1251,7 +1238,7 @@ def _post_init(self):
12511238
# extract the index display information from the form
12521239
self.columns = []
12531240
if self.form.has_key(':columns'):
1254-
self.columns = handleListCGIValue(None, self.form[':columns'])
1241+
self.columns = handleListCGIValue(self.form[':columns'])
12551242
self.show = ShowDict(self.columns)
12561243

12571244
# sorting
@@ -1279,7 +1266,7 @@ def _post_init(self):
12791266
# filtering
12801267
self.filter = []
12811268
if self.form.has_key(':filter'):
1282-
self.filter = handleListCGIValue(None, self.form[':filter'])
1269+
self.filter = handleListCGIValue(self.form[':filter'])
12831270
self.filterspec = {}
12841271
db = self.client.db
12851272
if self.classname is not None:
@@ -1290,8 +1277,8 @@ def _post_init(self):
12901277
fv = self.form[name]
12911278
if (isinstance(prop, hyperdb.Link) or
12921279
isinstance(prop, hyperdb.Multilink)):
1293-
cl = db.getclass(prop.classname)
1294-
self.filterspec[name] = handleListCGIValue(cl, fv)
1280+
self.filterspec[name] = lookupIds(db, prop,
1281+
handleListCGIValue(fv))
12951282
else:
12961283
self.filterspec[name] = fv.value
12971284

@@ -1357,7 +1344,7 @@ def __str__(self):
13571344
d.update(self.__dict__)
13581345
f = ''
13591346
for k in self.form.keys():
1360-
f += '\n %r=%r'%(k,handleListCGIValue(None, self.form[k]))
1347+
f += '\n %r=%r'%(k,handleListCGIValue(self.form[k]))
13611348
d['form'] = f
13621349
e = ''
13631350
for k,v in self.env.items():

0 commit comments

Comments
 (0)