当前位置: 首页>>代码示例>>Python>>正文


Python httpexceptions.HTTPForbidden方法代码示例

本文整理汇总了Python中pyramid.httpexceptions.HTTPForbidden方法的典型用法代码示例。如果您正苦于以下问题:Python httpexceptions.HTTPForbidden方法的具体用法?Python httpexceptions.HTTPForbidden怎么用?Python httpexceptions.HTTPForbidden使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在pyramid.httpexceptions的用法示例。


在下文中一共展示了httpexceptions.HTTPForbidden方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: unsubscribe

# 需要导入模块: from pyramid import httpexceptions [as 别名]
# 或者: from pyramid.httpexceptions import HTTPForbidden [as 别名]
def unsubscribe(request):
    tutorials = request.context.tutorials
    tutorial = tutorials[0]
    lecture = tutorial.lecture
    ls = request.db.query(models.LectureStudent).get((lecture.id, request.user.id))
    if not ls or ls.tutorial_id != tutorial.id:
        return HTTPForbidden('Sie sind zu dieser Übungsgruppe nicht angemeldet')
    lrs = request.db.query(models.LectureRemovedStudent).get((lecture.id, request.user.id))
    if not lrs:
        lrs = models.LectureRemovedStudent()
        lrs.lecture = lecture
        lrs.student = request.user
    lrs.tutorial = tutorial
    if not lrs in request.db: request.db.add(lrs)
    request.db.delete(ls)
    request.db.commit()
    sendChangesMailUnsubscribe(request, tutorial, request.user)
    request.session.flash('Erfolgreich aus Übungsgruppe ausgetragen', queue='messages')
    return HTTPFound(location=request.route_url('overview')) 
开发者ID:muesli-hd,项目名称:muesli,代码行数:21,代码来源:viewsTutorial.py

示例2: confirmEmail

# 需要导入模块: from pyramid import httpexceptions [as 别名]
# 或者: from pyramid.httpexceptions import HTTPForbidden [as 别名]
def confirmEmail(request):
    done = False
    aborted = False
    if request.context.confirmation.source != 'user/change_email':
        return HTTPForbidden('This confirmation is not for a email change')
    if request.POST.get('confirm'):
        user = request.context.confirmation.user
        user.email = request.context.confirmation.what
        request.db.delete(request.context.confirmation)
        request.db.commit()
        done = True
    elif request.POST.get('abort'):
        request.db.delete(request.context.confirmation)
        aborted = True
        request.db.commit()
    #       registerCommon(request, form)
    #       return HTTPFound(location=request.route_url('user_wait_for_confirmation'))
    return {'done': done,
            'aborted': aborted,
            'confirmation': request.context.confirmation} 
开发者ID:muesli-hd,项目名称:muesli,代码行数:22,代码来源:viewsUser.py

示例3: doAllocation

# 需要导入模块: from pyramid import httpexceptions [as 别名]
# 或者: from pyramid.httpexceptions import HTTPForbidden [as 别名]
def doAllocation(request):
    db = request.db
    lecture = request.context.lecture
    if not lecture.mode == 'prefs':
        return HTTPForbidden('This lecture is not in preferences mode')
    allocation = Allocation(lecture)
    result = allocation.doAllocation()
    prefs = {}
    for student in set(result['students_unhappy']+result['students_without_group']):
        p = [tp for tp in student.time_preferences if tp.lecture_id==lecture.id and tp.penalty < utils.students_unhappiness]
        prefs[student.id] = p
    lecture.mode = 'off'
    db.commit()
    return {'lecture': lecture,
                    'result': result,
                    'prefs': prefs} 
开发者ID:muesli-hd,项目名称:muesli,代码行数:18,代码来源:viewsLecture.py

示例4: hello

# 需要导入模块: from pyramid import httpexceptions [as 别名]
# 或者: from pyramid.httpexceptions import HTTPForbidden [as 别名]
def hello(request):
    """Say hello."""
    if request.openapi_validated.parameters["query"]["name"] == "admin":
        raise HTTPForbidden()
    return {"hello": request.openapi_validated.parameters["query"]["name"]} 
开发者ID:Pylons,项目名称:pyramid_openapi3,代码行数:7,代码来源:app.py

示例5: iter_content

# 需要导入模块: from pyramid import httpexceptions [as 别名]
# 或者: from pyramid.httpexceptions import HTTPForbidden [as 别名]
def iter_content(self, **kwargs):
            try:
                yield self.render_content(list(self.data_generator))
            except TooMuchDataError as exc:
                raise HTTPForbidden(exc.public_message) 
开发者ID:CERT-Polska,项目名称:n6,代码行数:7,代码来源:renderers.py

示例6: unauthorized_handler

# 需要导入模块: from pyramid import httpexceptions [as 别名]
# 或者: from pyramid.httpexceptions import HTTPForbidden [as 别名]
def unauthorized_handler(context, request, renderer="json"):
    if (
        request.matched_route
        and request.matched_route.pattern.startswith("/admin")
        or "api-explorer" in request.url
    ):
        url = request.route_url("admin_action", action="sign_in")
        return HTTPFound(url)
    return HTTPForbidden() 
开发者ID:Channelstream,项目名称:channelstream,代码行数:11,代码来源:error_handlers.py

示例7: checkTutorials

# 需要导入模块: from pyramid import httpexceptions [as 别名]
# 或者: from pyramid.httpexceptions import HTTPForbidden [as 别名]
def checkTutorials(tutorials):
    if tutorials:
        lecture_id = tutorials[0].lecture_id
        for tutorial in tutorials:
            if tutorial.lecture_id != lecture_id:
                raise HTTPForbidden('Tutorials belong to different lectures!') 
开发者ID:muesli-hd,项目名称:muesli,代码行数:8,代码来源:context.py

示例8: __call__

# 需要导入模块: from pyramid import httpexceptions [as 别名]
# 或者: from pyramid.httpexceptions import HTTPForbidden [as 别名]
def __call__(self):
        lecture = self.db.query(models.Lecture).get(self.lecture_id)
        tutorials = lecture.tutorials
        if self.request.method == 'POST':
            student_email = self.request.POST['student_email']
            new_tutorial  = int(self.request.POST['new_tutorial'])
            try:
                student = self.db.query(models.User).filter(models.User.email==student_email).one()
            except exc.NoResultFound:
                self.request.session.flash('Emailadresse nicht gefunden!', queue='errors')
                return {'lecture': lecture,
                        'tutorials': tutorials
                        }
            tutorial = [t for t in tutorials if t.id == new_tutorial]
            if len(tutorial)!=1:
                raise HTTPForbidden('Tutorial gehoert nicht zu dieser Vorlesung!')
            tutorial = tutorial[0]
            if student in lecture.students.all():
                self.request.session.flash('Der Student ist in diese Vorlesung bereits eingetragen!', queue='errors')
            else:
                lrs = self.request.db.query(models.LectureRemovedStudent).get((lecture.id, student.id))
                if lrs:
                    self.request.db.delete(lrs)
                #ls = request.db.query(models.LectureStudent).get((lecture.id, request.user.id))
                #if ls:
                #       oldtutorial = ls.tutorial
                #else:
                ls = models.LectureStudent()
                ls.lecture = lecture
                ls.student = student
                oldtutorial = None
                ls.tutorial = tutorial
                if not ls in self.request.db: self.request.db.add(ls)
                self.request.db.commit()
                self.request.session.flash('Der Student %s wurde in das Tutorial %s (%s) eingetragen' % (student, tutorial.time.__html__(), tutorial.tutor_name), queue='messages')
        return {'lecture': lecture,
                'tutorials': tutorials
                } 
开发者ID:muesli-hd,项目名称:muesli,代码行数:40,代码来源:viewsLecture.py


注:本文中的pyramid.httpexceptions.HTTPForbidden方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。