code: def attach_session(self):
          
          assert self.session is None
          root = self.find_root()
          session = self.Session(root)
          root.inject_context(session=session)
          return session
docs: Create a session and inject it as context for this command and any
          subcommands.