Mercurial > p > roundup > code
changeset 5095:d3ba0b254dbb
The patch to implement:
Validate properties specified for sorting and grouping in index
views. Original patch from martin.v.loewis via:
https://hg.python.org/tracker/roundup/rev/439bd3060df2
Applied by John Rouillard with some modification to properly
identify if the bad property is a sort or grouping property. Tests
added.
has an issue with the current code base. Apparently sometime it can be
entered without self.classname being defined. As a result the property
lookup fails. So guard it by checking for self.classname in a couple
of spots and if self.classname is not set just append the property
and let the target action sort it out.
| author | John Rouillard <rouilj@ieee.org> |
|---|---|
| date | Wed, 22 Jun 2016 21:29:14 -0400 |
| parents | 92d33d3125a0 |
| children | e74c3611b138 |
| files | roundup/cgi/templating.py |
| diffstat | 1 files changed, 9 insertions(+), 2 deletions(-) [+] |
line wrap: on
line diff
--- a/roundup/cgi/templating.py Tue Jun 21 21:45:24 2016 -0400 +++ b/roundup/cgi/templating.py Wed Jun 22 21:29:14 2016 -0400 @@ -2517,7 +2517,12 @@ dirs.append(self.form.getfirst(dirkey)) if fields: # only try other special char if nothing found break - cls = self.client.db.getclass(self.classname) + + # sometimes requests come in without a class + # chances are they won't have any filter params, + # in that case anyway but... + if self.classname: + cls = self.client.db.getclass(self.classname) for f, d in map(None, fields, dirs): if f.startswith('-'): dir, propname = '-', f[1:] @@ -2525,7 +2530,9 @@ dir, propname = '-', f else: dir, propname = '+', f - if cls.get_transitive_prop(propname) is None: + # if no classname, just append the propname unchecked. + # this may be valid for some actions that bypass classes. + if self.classname and cls.get_transitive_prop(propname) is None: self.client.add_error_message("Unknown %s property %s"%(name, propname)) else: var.append((dir, propname))
