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