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


Python web.notfound方法代码示例

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


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

示例1: process_callback

# 需要导入模块: import web [as 别名]
# 或者: from web import notfound [as 别名]
def process_callback(self, auth_id):
        auth_method = self.user_manager.get_auth_method(auth_id)
        if not auth_method:
            raise web.notfound()

        auth_storage = self.user_manager.session_auth_storage().setdefault(auth_id, {})
        user = auth_method.callback(auth_storage)
        if user and auth_storage.get("method", "") == "signin":
            if not self.user_manager.bind_user(auth_id, user):
                raise web.seeother("/signin?binderror")
        elif user and auth_storage.get("method", "") == "share":
            submission = self.submission_manager.get_submission(auth_storage["submissionid"], True)
            if submission:
                course = self.course_factory.get_course(submission["courseid"])
                task = course.get_task(submission["taskid"])
                auth_method.share(auth_storage, course, task, submission, self.user_manager.session_language())
            else:
                raise web.notfound()
        else:
            raise web.seeother("/signin?callbackerror")

        raise web.seeother(auth_storage.get("redir_url", "/")) 
开发者ID:UCL-INGI,项目名称:INGInious,代码行数:24,代码来源:social.py

示例2: GET

# 需要导入模块: import web [as 别名]
# 或者: from web import notfound [as 别名]
def GET(self):
        """
            Checks if user is authenticated and calls POST_AUTH or performs login and calls GET_AUTH.
            Otherwise, returns the login template.
        """
        data = self.user_manager.session_lti_info()
        if data is None:
            raise web.notfound()

        try:
            course = self.course_factory.get_course(data["task"][0])
            if data["consumer_key"] not in course.lti_keys().keys():
                raise Exception()
        except:
            return self.template_helper.get_renderer().lti_bind(False, "", None, "Invalid LTI data")

        user_profile = self.database.users.find_one({"ltibindings." + data["task"][0] + "." + data["consumer_key"]: data["username"]})
        if user_profile:
            self.user_manager.connect_user(user_profile["username"], user_profile["realname"], user_profile["email"], user_profile["language"])

        if self.user_manager.session_logged_in():
            raise web.seeother(self.app.get_homepath() + "/lti/task")

        return self.template_helper.get_renderer().lti_login(False) 
开发者ID:UCL-INGI,项目名称:INGInious,代码行数:26,代码来源:lti.py

示例3: GET_AUTH

# 需要导入模块: import web [as 别名]
# 或者: from web import notfound [as 别名]
def GET_AUTH(self, courseid, groupid=''):  # pylint: disable=arguments-differ
        """ Edit a group """
        course, __ = self.get_course_and_check_rights(courseid, allow_all_staff=True)

        if course.is_lti():
            raise web.notfound()

        if "download" in web.input():
            web.header('Content-Type', 'text/x-yaml', unique=True)
            web.header('Content-Disposition', 'attachment; filename="groups.yaml"', unique=True)
            groups = [{"description": group["description"],
                           "students": group["students"],
                           "size": group["size"],
                            "audiences": [str(c) for c in group["audiences"]]} for group in
                          self.user_manager.get_course_groups(course)]

            return yaml.dump(groups)

        return self.display_page(course) 
开发者ID:UCL-INGI,项目名称:INGInious,代码行数:21,代码来源:group_edit.py

示例4: GET_AUTH

# 需要导入模块: import web [as 别名]
# 或者: from web import notfound [as 别名]
def GET_AUTH(self, courseid):  # pylint: disable=arguments-differ
        """ GET request """
        course, __ = self.get_course_and_check_rights(courseid)
        user_input = web.input(tasks=[], aggregations=[], users=[])
        error = ""

        # First, check for a particular submission
        if "submission" in user_input:
            submission = self.database.submissions.find_one({"_id": ObjectId(user_input.submission),
                                                             "courseid": course.get_id(),
                                                             "status": {"$in": ["done", "error"]}})
            if submission is None:
                raise web.notfound()

            self._logger.info("Downloading submission %s - %s - %s - %s", submission['_id'], submission['courseid'],
                              submission['taskid'], submission['username'])
            archive, error = self.submission_manager.get_submission_archive(course, [submission], [])
            if not error:
                web.header('Content-Type', 'application/x-gzip', unique=True)
                web.header('Content-Disposition', 'attachment; filename="submissions.tgz"', unique=True)
                return archive

        # Else, display the complete page
        return self.display_page(course, user_input, error) 
开发者ID:UCL-INGI,项目名称:INGInious,代码行数:26,代码来源:download.py

示例5: get_course_and_check_rights

# 需要导入模块: import web [as 别名]
# 或者: from web import notfound [as 别名]
def get_course_and_check_rights(self, courseid, taskid=None, allow_all_staff=True):
        """ Returns the course with id ``courseid`` and the task with id ``taskid``, and verify the rights of the user.
            Raise web.notfound() when there is no such course of if the users has not enough rights.

            :param courseid: the course on which to check rights
            :param taskid: If not None, returns also the task with id ``taskid``
            :param allow_all_staff: allow admins AND tutors to see the page. If false, all only admins.
            :returns (Course, Task)
        """

        try:
            course = self.course_factory.get_course(courseid)
            if allow_all_staff:
                if not self.user_manager.has_staff_rights_on_course(course):
                    raise web.notfound()
            else:
                if not self.user_manager.has_admin_rights_on_course(course):
                    raise web.notfound()

            if taskid is None:
                return course, None
            else:
                return course, course.get_task(taskid)
        except:
            raise web.notfound() 
开发者ID:UCL-INGI,项目名称:INGInious,代码行数:27,代码来源:utils.py

示例6: action_download

# 需要导入模块: import web [as 别名]
# 或者: from web import notfound [as 别名]
def action_download(self, courseid, taskid, path):
        """ Download a file or a directory """

        wanted_path = self.verify_path(courseid, taskid, path)
        if wanted_path is None:
            raise web.notfound()

        task_fs = self.task_factory.get_task_fs(courseid, taskid)
        (method, mimetype_or_none, file_or_url) = task_fs.distribute(wanted_path)

        if method == "local":
            web.header('Content-Type', mimetype_or_none)
            return file_or_url
        elif method == "url":
            raise web.redirect(file_or_url)
        else:
            raise web.notfound() 
开发者ID:UCL-INGI,项目名称:INGInious,代码行数:19,代码来源:task_edit_file.py

示例7: POST_AUTH

# 需要导入模块: import web [as 别名]
# 或者: from web import notfound [as 别名]
def POST_AUTH(self, courseid):  # pylint: disable=arguments-differ
        """ POST request """
        course, __ = self.get_course_and_check_rights(courseid)
        msgs = []

        if "replay" in web.input():
            if not self.user_manager.has_admin_rights_on_course(course):
                raise web.notfound()

            input = self.get_input()
            tasks = course.get_tasks()
            data, __ = self.get_submissions(course, input)
            for submission in data:
                self.submission_manager.replay_job(tasks[submission["taskid"]], submission)
            msgs.append(_("{0} selected submissions were set for replay.").format(str(len(data))))

        return self.page(course, msgs) 
开发者ID:UCL-INGI,项目名称:INGInious,代码行数:19,代码来源:submissions.py

示例8: POST

# 需要导入模块: import web [as 别名]
# 或者: from web import notfound [as 别名]
def POST(self):
        """ Handles POST request """
        if self.user_manager.session_logged_in() or not self.app.allow_registration:
            raise web.notfound()

        reset = None
        msg = ""
        error = False
        data = web.input()
        if "register" in data:
            msg, error = self.register_user(data)
        elif "lostpasswd" in data:
            msg, error = self.lost_passwd(data)
        elif "resetpasswd" in data:
            msg, error, reset = self.get_reset_data(data)
            if reset:
                msg, error = self.reset_passwd(data)
            if not error:
                reset = None

        return self.template_helper.get_renderer().register(reset, msg, error) 
开发者ID:UCL-INGI,项目名称:INGInious,代码行数:23,代码来源:register.py

示例9: GET

# 需要导入模块: import web [as 别名]
# 或者: from web import notfound [as 别名]
def GET(self,name):
        ext = name.split(".")[-1] # Gather extension
        if name.find('.')<0:
            ext = 'jpg'
        imfile = self.get_local( os.path.splitext(name)[0] )
        #print imfile
        try:
            web.header("Content-Type", cType[ext]) # Set the Header
            return open(imfile,"rb").read() # Notice 'rb' for reading images
        except:
            raise web.notfound() 
开发者ID:li-xirong,项目名称:jingwei,代码行数:13,代码来源:images.py

示例10: GET

# 需要导入模块: import web [as 别名]
# 或者: from web import notfound [as 别名]
def GET(self, id=None):
        global db, nextid

        if(len(id) == 0):
            return json.dumps(db)
        elif(int(id) in db):
            return json.dumps(db[int(id)])
        else:
            return web.notfound() 
开发者ID:agusmakmun,项目名称:Some-Examples-of-Simple-Python-Script,代码行数:11,代码来源:restful_webapi.py

示例11: DELETE

# 需要导入模块: import web [as 别名]
# 或者: from web import notfound [as 别名]
def DELETE(self, id):
        global db, nextid

        if(int(id) in db):
            db.pop(int(id))
            return json.dumps({'deleted': int(id)})
        else:
            return web.notfound() 
开发者ID:agusmakmun,项目名称:Some-Examples-of-Simple-Python-Script,代码行数:10,代码来源:restful_webapi.py

示例12: PUT

# 需要导入模块: import web [as 别名]
# 或者: from web import notfound [as 别名]
def PUT(self, id):
        global db, nextid

        if(int(id) in db):
            db[int(id)] = json.loads(web.data())
            return json.dumps({'updated': int(id)})
        else:
            return web.notfound() 
开发者ID:agusmakmun,项目名称:Some-Examples-of-Simple-Python-Script,代码行数:10,代码来源:restful_webapi.py

示例13: basic_checks

# 需要导入模块: import web [as 别名]
# 或者: from web import notfound [as 别名]
def basic_checks(self, courseid):
        try:
            course = self.course_factory.get_course(courseid)
        except:
            raise web.notfound()

        username = self.user_manager.session_username()
        user_info = self.user_manager.get_user_info(username)

        if self.user_manager.course_is_user_registered(course, username) or not course.is_registration_possible(user_info):
            raise web.seeother(self.app.get_homepath() + "/course/" + course.get_id())

        return course, username 
开发者ID:UCL-INGI,项目名称:INGInious,代码行数:15,代码来源:course_register.py

示例14: process_signin

# 需要导入模块: import web [as 别名]
# 或者: from web import notfound [as 别名]
def process_signin(self,auth_id):
        auth_method = self.user_manager.get_auth_method(auth_id)
        if not auth_method:
            raise web.notfound()

        auth_storage = self.user_manager.session_auth_storage().setdefault(auth_id, {})
        auth_storage["redir_url"] = web.ctx.env.get('HTTP_REFERER', '/')
        auth_storage["method"] = "signin"
        auth_link = auth_method.get_auth_link(auth_storage)
        raise web.seeother(auth_link) 
开发者ID:UCL-INGI,项目名称:INGInious,代码行数:12,代码来源:social.py

示例15: process_share

# 需要导入模块: import web [as 别名]
# 或者: from web import notfound [as 别名]
def process_share(self, auth_id):
        auth_method = self.user_manager.get_auth_method(auth_id)
        if not auth_method:
            raise web.notfound()

        auth_storage = self.user_manager.session_auth_storage().setdefault(auth_id, {})
        auth_storage["redir_url"] = web.ctx.env.get('HTTP_REFERER', '/')
        auth_storage["method"] = "share"
        auth_storage["submissionid"] = web.input().get("submissionid", "")
        auth_link = auth_method.get_auth_link(auth_storage, True)
        raise web.seeother(auth_link) 
开发者ID:UCL-INGI,项目名称:INGInious,代码行数:13,代码来源:social.py


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