From 32c6dad52601f4b2e336c005d54def87b1caf74e Mon Sep 17 00:00:00 2001
From: Usman Khalid <2200617@gmail.com>
Date: Fri, 12 Sep 2014 19:51:25 +0500
Subject: [PATCH] Moved imports to manage.py and wsgi.py.

---
 cms/startup.py         | 4 ----
 cms/wsgi.py            | 4 ++++
 lms/startup.py         | 5 -----
 lms/wsgi.py            | 4 ++++
 lms/wsgi_apache_lms.py | 4 ++++
 manage.py              | 4 ++++
 6 files changed, 16 insertions(+), 9 deletions(-)

diff --git a/cms/startup.py b/cms/startup.py
index 86586e8f7c1..815b03ecea9 100644
--- a/cms/startup.py
+++ b/cms/startup.py
@@ -15,10 +15,6 @@ def run():
     """
     Executed during django startup
     """
-    # Patch the xml libs.
-    from safe_lxml import defuse_xml_libs
-    defuse_xml_libs()
-
     django_utils_translation.patch()
 
     autostartup()
diff --git a/cms/wsgi.py b/cms/wsgi.py
index 70dba18d7ff..199d3939eea 100644
--- a/cms/wsgi.py
+++ b/cms/wsgi.py
@@ -1,3 +1,7 @@
+# Patch the xml libs before anything else.
+from safe_lxml import defuse_xml_libs
+defuse_xml_libs()
+
 # Disable PyContract contract checking when running as a webserver
 import contracts
 contracts.disable_all()
diff --git a/lms/startup.py b/lms/startup.py
index 5d789c51461..bb6b312a509 100644
--- a/lms/startup.py
+++ b/lms/startup.py
@@ -20,11 +20,6 @@ def run():
     """
     Executed during django startup
     """
-
-    # Patch the xml libs.
-    from safe_lxml import defuse_xml_libs
-    defuse_xml_libs()
-
     django_utils_translation.patch()
 
     autostartup()
diff --git a/lms/wsgi.py b/lms/wsgi.py
index 4fe5b0b79f2..1f7a0e37c7b 100644
--- a/lms/wsgi.py
+++ b/lms/wsgi.py
@@ -1,3 +1,7 @@
+# Patch the xml libs
+from safe_lxml import defuse_xml_libs
+defuse_xml_libs()
+
 # Disable PyContract contract checking when running as a webserver
 import contracts
 contracts.disable_all()
diff --git a/lms/wsgi_apache_lms.py b/lms/wsgi_apache_lms.py
index 41c3317e148..c69bb5f4984 100644
--- a/lms/wsgi_apache_lms.py
+++ b/lms/wsgi_apache_lms.py
@@ -1,3 +1,7 @@
+# Patch the xml libs before anything else.
+from safe_lxml import defuse_xml_libs
+defuse_xml_libs()
+
 import os
 
 os.environ.setdefault("DJANGO_SETTINGS_MODULE", "lms.envs.aws")
diff --git a/manage.py b/manage.py
index a5c6e5fb2ba..ce48d914eee 100755
--- a/manage.py
+++ b/manage.py
@@ -11,6 +11,10 @@ by passing the --settings flag, you can specify what environment specific settin
 Any arguments not understood by this manage.py will be passed to django-admin.py
 """
 
+# Patch the xml libs before anything else.
+from safe_lxml import defuse_xml_libs
+defuse_xml_libs()
+
 import os
 import sys
 import importlib
-- 
GitLab