__init__.py 文件源码

python
阅读 23 收藏 0 点赞 0 评论 0

项目:stalker_pyramid 作者: eoyilmaz 项目源码 文件源码
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!')
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号