##// END OF EJS Templates
get_or_404 method does validation for ID beeing an INT
marcink -
r2942:f53faff4 beta
parent child Browse files
Show More
@@ -118,11 +118,15 b' class BaseModel(object):'
118 118
119 119 @classmethod
120 120 def get_or_404(cls, id_):
121 if id_:
122 res = cls.query().get(id_)
123 if not res:
124 raise HTTPNotFound
125 return res
121 try:
122 id_ = int(id_)
123 except (TypeError, ValueError):
124 raise HTTPNotFound
125
126 res = cls.query().get(id_)
127 if not res:
128 raise HTTPNotFound
129 return res
126 130
127 131 @classmethod
128 132 def getAll(cls):
General Comments 0
You need to be logged in to leave comments. Login now