Move the `open_environment` from `trac.web.main` to `trac.env`. This function is responsible for the thread-safe caching of environments, and automatically performing the check for needed upgrades, features which may be generally useful outside of the web frontend.