diff --git a/frappe/__init__.py b/frappe/__init__.py index 141da8f48b..a3fd020499 100644 --- a/frappe/__init__.py +++ b/frappe/__init__.py @@ -85,7 +85,7 @@ message_log = local("message_log") lang = local("lang") -def init(site, sites_path=None): +def init(site, sites_path=None, new_site=False): """Initialize frappe for the current site. Reset thread locals `frappe.local`""" if getattr(local, "initialised", None): return @@ -108,6 +108,7 @@ def init(site, sites_path=None): "ignore_links": False, "mute_emails": False, "has_dataurl": False, + "new_site": new_site }) local.rollback_observers = [] local.test_objects = {} @@ -173,7 +174,7 @@ def get_site_config(sites_path=None, site_path=None): site_config = os.path.join(site_path, "site_config.json") if os.path.exists(site_config): config.update(get_file_json(site_config)) - elif local.site: + elif local.site and not local.flags.new_site: raise IncorrectSitePath, "{0} does not exist".format(site_config) return _dict(config) diff --git a/frappe/commands.py b/frappe/commands.py index 1e0551dfe3..ca50d6f713 100644 --- a/frappe/commands.py +++ b/frappe/commands.py @@ -65,7 +65,7 @@ def new_site(site, mariadb_root_username=None, mariadb_root_password=None, admin if not db_name: db_name = hashlib.sha1(site).hexdigest()[:10] - frappe.init(site=site) + frappe.init(site=site, new_site=True) _new_site(db_name, site, mariadb_root_username=mariadb_root_username, mariadb_root_password=mariadb_root_password, admin_password=admin_password, verbose=verbose, install_apps=install_app, source_sql=source_sql, force=force) if len(frappe.utils.get_sites()) == 1: use(site)