def METHOD_NAME(self, filename=None, template=None, services=None):
    """Initialize an application session."""
    session = Session(services=services)
    @event_handler(ActiveSessionChanged)
    def on_active_session_changed(event):
        logger.debug("Set active session to %s", session)
        self._active_session = session
    @event_handler(SessionShutdown)
    def on_session_shutdown(event):
        self.shutdown_session(session)
        if not self._sessions:
            self.quit()
    event_manager = session.get_service("event_manager")
    event_manager.subscribe(on_active_session_changed)
    event_manager.subscribe(on_session_shutdown)
    self._sessions.add(session)
    session_created = SessionCreated(self, session, filename, template)
    event_manager.handle(session_created)
    self.event_manager.handle(session_created)
    session.foreground()
    return session