aboutsummaryrefslogtreecommitdiff
path: root/rhodecode/model/db.py
diff options
context:
space:
mode:
authorMarcin Kuzminski <marcin@python-works.com>2012-06-20 21:42:05 +0200
committerMarcin Kuzminski <marcin@python-works.com>2012-06-20 21:42:05 +0200
commiteeeabe54361be36cebb34b8259018f117dbbe57a (patch)
tree199daa49381d8eb2c509dfa6efd0a3125670ef37 /rhodecode/model/db.py
parentfb27e837780d0c50743f5b2a12d7027658c6b589 (diff)
use get_or_404 where possible
--HG-- branch : beta extra : rebase_source : 558362caa287644f192239fbb9d7c0509c0acd1c
Diffstat (limited to 'rhodecode/model/db.py')
-rwxr-xr-xrhodecode/model/db.py10
1 files changed, 10 insertions, 0 deletions
diff --git a/rhodecode/model/db.py b/rhodecode/model/db.py
index d17f4baa..2a090bc1 100755
--- a/rhodecode/model/db.py
+++ b/rhodecode/model/db.py
@@ -35,6 +35,7 @@ from sqlalchemy.ext.hybrid import hybrid_property
from sqlalchemy.orm import relationship, joinedload, class_mapper, validates
from sqlalchemy.exc import DatabaseError
from beaker.cache import cache_region, region_invalidate
+from webob.exc import HTTPNotFound
from pylons.i18n.translation import lazy_ugettext as _
@@ -51,6 +52,7 @@ from rhodecode.lib.caching_query import FromCache
from rhodecode.model.meta import Base, Session
+
URL_SEP = '/'
log = logging.getLogger(__name__)
@@ -142,6 +144,14 @@ class BaseModel(object):
return cls.query().get(id_)
@classmethod
+ def get_or_404(cls, id_):
+ if id_:
+ res = cls.query().get(id_)
+ if not res:
+ raise HTTPNotFound
+ return res
+
+ @classmethod
def getAll(cls):
return cls.query().all()