In my script, I add a page (scene) for a 2D view. I later delete the page, and restore the view. All works fine, unless I immediately save the model. If I then reload the model, I’ll get that 2D view, not the view that was on the screen when I saved.
This simplified test script illustrates the issue:
If you run that, it will pause to show you the 2D view (in this case, looking down on the origin). Resume, and the view will be restored. Now don’t change the view, save the model, and then reload it. You’ll see that ugly 2D view. One workaround is the save pages.selected_page before I start, and restore that at the end, but that won’t work if there were no pages to start with.