timApp package#

Subpackages#

Submodules#

timApp.debugconfig module#

timApp.defaultconfig module#

List and defaults for all configuration options in TIM.

Note

Please don’t modify this file directly in your server or local development setup. This avoids merge conflicts. Override the values with prodconfig.py or debugconfig.py instead.

timApp.defaultconfig.LOG_USER_SELECT_ACTIONS = False#

Log any actions applied via UserSelect component.

timApp.defaultconfig.SESSIONS_ENABLE = False#

If enabled, session management information will be stored and logged.

timApp.defaultconfig.SESSIONS_MAX_CONCURRENT_SESSIONS_PER_USER = 1#

How many concurrent sessions are allowed for a single user for a protected document. If this limit is reached, the user is not given an active session which prevents accessing documents.

If None, there is no limit.

timApp.defaultconfig.SESSION_BLOCK_IGNORE_DOCUMENTS = {}#

Paths of documents that should be ignored when blocking sessions. All users will be able to access the document regardless of the session blocking.

timApp.defaultconfig.SYNC_USER_GROUPS_HOSTS = []#

Groups to sync user group info to.

timApp.defaultconfig.SYNC_USER_GROUPS_RECEIVE_SECRET = None#

Secret to check against when syncing group info.

timApp.defaultconfig.SYNC_USER_GROUPS_SEND_SECRET = None#

Secret to use to when syncing user group info. If None, no user group memberships.

..note: Right now, syncing only is done in UserSelect.

timApp.errorhandlers module#

exception timApp.errorhandlers.SuppressedError(msg: str)[source]#

Bases: Exception

msg: str#
timApp.errorhandlers.register_errorhandlers(app: flask.app.Flask)[source]#
timApp.errorhandlers.suppress_wuff(ex_type: type[Exception], details_url: str, message_regex: Optional[str] = None) Callable[source]#

Decorator to prevent sending email errors (“wuffs”) on the specified error.

The decorator is meant to suppress well-known errors that are marked for fixing and are not critical for TIM to function. When decorating a function, it is suggested to include a comment that links to a clear description of the problem.

Parameters
  • ex_type – Exception type to suppress

  • details_url – URL to a page with details about the issue (e.g. issue URL)

  • message_regex – RegEx to check messages exception messages against. If specified, exception is also matched against the message.

Returns

Wrapped function

timApp.gunicornconf module#

timApp.gunicornconf.post_fork(server: Any, worker: Any) None[source]#

timApp.launch module#

timApp.launch.quit_fast(_sig: int, _frame: frame | None) None[source]#

timApp.profileconfig module#

timApp.testconfig module#

class timApp.testconfig.Schedule[source]#

Bases: TypedDict

schedule: celery.schedules.crontab#
task: str#

timApp.tim module#

class timApp.tim.GetProxyModel(url: str, auth_token: str | None = None, raw: bool = False, mimetype: str | None = None, file: bool = False)[source]#

Bases: object

auth_token: str | None = None#
file: bool = False#
mimetype: str | None = None#
raw: bool = False#
url: str#
timApp.tim.after_request(resp: flask.wrappers.Response)[source]#
timApp.tim.close_db(response)[source]#
timApp.tim.close_db_appcontext(_e)[source]#
timApp.tim.del_g(response)[source]#

For some reason, the g object is not cleared when running browser test, so we do it here.

timApp.tim.empty_response_route()[source]#
timApp.tim.get_angularscripts(index_file: str, locale: Optional[str] = None)[source]#
timApp.tim.get_js_file(path: str)[source]#
timApp.tim.get_locale()[source]#
timApp.tim.get_templates(item_path: str) flask.wrappers.Response[source]#
timApp.tim.get_time()[source]#
timApp.tim.getproxy(m: timApp.tim.GetProxyModel)[source]#
timApp.tim.init_app()[source]#
timApp.tim.inject_angular_scripts() dict[source]#

Provides the JavaScript files compiled by Angular.

timApp.tim.inject_user() dict[source]#

“Injects user-related info to all templates.

timApp.tim.install_sql_hook()[source]#
timApp.tim.log_request(response)[source]#
timApp.tim.ping()[source]#
timApp.tim.preprocess_request()[source]#
timApp.tim.should_log_request()[source]#
timApp.tim.start_app() None[source]#
timApp.tim.start_page()[source]#
timApp.tim.update_user_course_bookmarks()[source]#

timApp.tim_app module#

Creates the Flask application for TIM.

Insert only configuration-related things in this file. Do NOT define routes here.

timApp.tim_app.get_home_organization_group() timApp.user.usergroup.UserGroup[source]#
timApp.tim_app.make_shell_context()[source]#
timApp.tim_app.print_schema(bind: Optional[str] = None)[source]#

Prints the database schema generated by the models.

Parameters

bind – The bind to use.

timApp.tim_celery module#

Contains initialization of Celery distributed task queue and task functions. Note: Add new tasks here. For scheduling add parameters to defaultconfig as well.

timApp.tim_celery.do_run_user_function(user_id: int, task_id: str, plugin_input: dict[str, Any])[source]#
timApp.tim_celery.do_send_answer_backup(exported_answer: dict[str, Any])[source]#
timApp.tim_celery.do_send_user_group_info(email: str, user_memberships: list[str])[source]#
timApp.tim_celery.handle_exportdata(result: timApp.answer.routes.AnswerRouteResult, u: timApp.user.user.User, wod: timApp.plugin.exportdata.WithOutData) None[source]#
timApp.tim_celery.make_celery(appl)[source]#

Initializes Celery.

Parameters

appl – Flask app.

Returns

Celery.

timApp.tim_celery.on_after_setup_logger(**kwargs)[source]#

timApp.timtypes module#

Sometimes, using type annotations require imports that would cause circular imports.

To work around it, this module defines aliases for the types that can be imported instead.

TODO: These are broken at the moment after timApp reorganization.

Module contents#