當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。