def __init__(self, request):
self.request = request
self.entity_id = request.matchdict.get('id')
self.entity = None
if self.entity_id:
from stalker import SimpleEntity
from sqlalchemy.exc import DataError
try:
self.entity = SimpleEntity.query\
.filter(SimpleEntity.id == self.entity_id).first()
except DataError:
self.entity = None
if not self.entity:
from pyramid.exceptions import HTTPNotFound
raise HTTPNotFound('Entity not found!')
评论列表
文章目录