Show More
@@ -42,7 +42,6 b' from sqlalchemy.orm import (' | |||||
42 | relationship, joinedload, class_mapper, validates, aliased) |
|
42 | relationship, joinedload, class_mapper, validates, aliased) | |
43 | from sqlalchemy.sql.expression import true |
|
43 | from sqlalchemy.sql.expression import true | |
44 | from beaker.cache import cache_region |
|
44 | from beaker.cache import cache_region | |
45 | from webob.exc import HTTPNotFound |
|
|||
46 | from zope.cachedescriptors.property import Lazy as LazyProperty |
|
45 | from zope.cachedescriptors.property import Lazy as LazyProperty | |
47 |
|
46 | |||
48 | from pylons import url |
|
47 | from pylons import url | |
@@ -207,7 +206,14 b' class BaseModel(object):' | |||||
207 | return cls.query().get(id_) |
|
206 | return cls.query().get(id_) | |
208 |
|
207 | |||
209 | @classmethod |
|
208 | @classmethod | |
210 | def get_or_404(cls, id_): |
|
209 | def get_or_404(cls, id_, pyramid_exc=False): | |
|
210 | if pyramid_exc: | |||
|
211 | # NOTE(marcink): backward compat, once migration to pyramid | |||
|
212 | # this should only use pyramid exceptions | |||
|
213 | from pyramid.httpexceptions import HTTPNotFound | |||
|
214 | else: | |||
|
215 | from webob.exc import HTTPNotFound | |||
|
216 | ||||
211 | try: |
|
217 | try: | |
212 | id_ = int(id_) |
|
218 | id_ = int(id_) | |
213 | except (TypeError, ValueError): |
|
219 | except (TypeError, ValueError): | |
@@ -3624,7 +3630,13 b' class Gist(Base, BaseModel):' | |||||
3624 | return '<Gist:[%s]%s>' % (self.gist_type, self.gist_access_id) |
|
3630 | return '<Gist:[%s]%s>' % (self.gist_type, self.gist_access_id) | |
3625 |
|
3631 | |||
3626 | @classmethod |
|
3632 | @classmethod | |
3627 | def get_or_404(cls, id_): |
|
3633 | def get_or_404(cls, id_, pyramid_exc=False): | |
|
3634 | ||||
|
3635 | if pyramid_exc: | |||
|
3636 | from pyramid.httpexceptions import HTTPNotFound | |||
|
3637 | else: | |||
|
3638 | from webob.exc import HTTPNotFound | |||
|
3639 | ||||
3628 | res = cls.query().filter(cls.gist_access_id == id_).scalar() |
|
3640 | res = cls.query().filter(cls.gist_access_id == id_).scalar() | |
3629 | if not res: |
|
3641 | if not res: | |
3630 | raise HTTPNotFound |
|
3642 | raise HTTPNotFound |
General Comments 0
You need to be logged in to leave comments.
Login now