Base handler#

class GraderBaseHandler(application: grader_service.server.GraderServer, request: tornado.httputil.HTTPServerRequest, **kwargs: Any)[source]#

Base class of all handler classes that implements validation and request functions

async authenticate_token_user(token: str) Optional[dict][source]#
async authenticate_user()[source]#

This is a workaround for async authentication. get_current_user cannot be asynchronous and a request cannot be made in a blocking manner. This sets the current_user property before each request before being checked by the authenticated decorator.

construct_git_dir(repo_type: str, lecture: grader_service.orm.lecture.Lecture, assignment: grader_service.orm.assignment.Assignment, group_name: Optional[str] = None) Optional[str][source]#

Helper method for every handler that needs to access git directories which returns the path of the repository based on the inputs or None if the repo_type is not recognized.

data_received(chunk: bytes) Optional[Awaitable[None]][source]#

Implement this method to handle streamed request data.

Requires the .stream_request_body decorator.

May be a coroutine for flow control.

duplicate_release_repo(repo_path_release: str, repo_path_user: str, assignment: grader_service.orm.assignment.Assignment, message: str, checkout_main: bool = False)[source]#
get_assignment(lecture_id: int, assignment_id: int) grader_service.orm.assignment.Assignment[source]#
async get_current_user_async(token) Optional[dict][source]#
get_request_token() Optional[str][source]#
get_role(lecture_id: int) grader_service.orm.takepart.Role[source]#
get_submission(lecture_id: int, assignment_id: int, submission_id: int) grader_service.orm.submission.Submission[source]#
property gitbase#
hub_request_service = <grader_service.request.RequestService object>#
static is_base_git_dir(path: str) bool[source]#
async prepare() Optional[Awaitable[None]][source]#

Called at the beginning of a request before get/post/etc.

Override this method to perform common initialization regardless of the request method.

Asynchronous support: Use async def or decorate this method with .gen.coroutine to make it asynchronous. If this method returns an Awaitable execution will not proceed until the Awaitable is done.

New in version 3.1: Asynchronous support.

request_service = <grader_service.request.RequestService object>#
property user: grader_service.orm.user.User#
validate_parameters(*args)[source]#
write_error(status_code: int, **kwargs) None[source]#

Override to implement custom error pages.

write_error may call write, render, set_header, etc to produce output as usual.

If this error was caused by an uncaught exception (including HTTPError), an exc_info triple will be available as kwargs["exc_info"]. Note that this exception may not be the “current” exception for purposes of methods like sys.exc_info() or traceback.format_exc.

write_json(obj) None[source]#
class RequestHandlerConfig(**kwargs: Any)[source]#
autograde_executor_class#

A trait whose value must be a subclass of a specified class.

class VersionHandler(application: grader_service.server.GraderServer, request: tornado.httputil.HTTPServerRequest, **kwargs: Any)[source]#
async get()[source]#
hub_api_base_path: str#
class VersionHandlerV1(application: grader_service.server.GraderServer, request: tornado.httputil.HTTPServerRequest, **kwargs: Any)[source]#
async get()[source]#
hub_api_base_path: str#
authenticated(method: Callable[[...], Optional[Awaitable[None]]]) Callable[[...], Optional[Awaitable[None]]][source]#

Decorate methods with this to require that the user be logged in.

If the user is not logged in, an tornado.web.HTTPError with cod 403 will be raised.

authorize(scopes: List[grader_service.orm.takepart.Scope])[source]#

Checks if user is authorized. :param scopes: the user’s roles :return: wrapper function