Mercurial > kallithea
diff rhodecode/model/db.py @ 2942:f53faff4487e beta
get_or_404 method does validation for ID beeing an INT
author | Marcin Kuzminski <marcin@python-works.com> |
---|---|
date | Fri, 19 Oct 2012 23:44:35 +0200 |
parents | d439d408b415 |
children | 78227b65a358 |
line wrap: on
line diff
--- a/rhodecode/model/db.py Fri Oct 19 23:39:43 2012 +0200 +++ b/rhodecode/model/db.py Fri Oct 19 23:44:35 2012 +0200 @@ -118,11 +118,15 @@ @classmethod def get_or_404(cls, id_): - if id_: - res = cls.query().get(id_) - if not res: - raise HTTPNotFound - return res + try: + id_ = int(id_) + except (TypeError, ValueError): + raise HTTPNotFound + + res = cls.query().get(id_) + if not res: + raise HTTPNotFound + return res @classmethod def getAll(cls):