Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refactor Sessions to clarify their usage #366

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Commits on Dec 8, 2023

  1. Refactor Sessions to clarify their usage

    DBSession has been renamed to HandlerSession.
    
    The following exist now:
    - HandlerSession: a DB session scoped to the current handler;
      should therefore only be used inside handlers.
    - ThreadSession: a DB session scoped to the current thread;
      should be used outside of handlers, e.g. when firing off
      tasks in threads, or inside of services.
    
    A special HandlerSession, with knowledge of the current user, and that
    verifies permissions on commit, is available as `self.Session` on the
    base handler. This is the *preferred way of accessing* HandlerSession.
    
    To make it easier to get hold of the current engine, the Sessions each
    have a `.engine` attribute: `HandlerSession.engine`.
    
    This avoids having to access the engine as
    `HandlerSession.session_factory.kw["bind"]`.
    stefanv committed Dec 8, 2023
    Configuration menu
    Copy the full SHA
    3fdfdda View commit details
    Browse the repository at this point in the history
  2. Configuration menu
    Copy the full SHA
    379bb02 View commit details
    Browse the repository at this point in the history