From cd34c163cc862113da5b27bf9f5ff452f538fb2c Mon Sep 17 00:00:00 2001
From: Jacob Kaplan-Moss <jacob@jacobian.org>
Date: Tue, 27 Sep 2005 16:34:10 +0000
Subject: [PATCH] Moved JING from django.core.validators into settings where it
 belongs.  Fixes #568.

git-svn-id: http://code.djangoproject.com/svn/django/trunk@712 bcc190cf-cafb-0310-a4f2-bffc1f526a37
---
 django/conf/global_settings.py | 3 +++
 django/core/validators.py      | 8 ++++----
 2 files changed, 7 insertions(+), 4 deletions(-)

diff --git a/django/conf/global_settings.py b/django/conf/global_settings.py
index 9876713718..449d25d01e 100644
--- a/django/conf/global_settings.py
+++ b/django/conf/global_settings.py
@@ -109,6 +109,9 @@ IGNORABLE_404_ENDS = ('mail.pl', 'mailform.pl', 'mail.cgi', 'mailform.cgi', 'fav
 # loudly.
 SECRET_KEY = ''
 
+# Path to the "jing" executable -- needed to validate XMLFields
+JING_PATH = "/usr/bin/jng"
+
 ##############
 # MIDDLEWARE #
 ##############
diff --git a/django/core/validators.py b/django/core/validators.py
index 6714bfda3e..697c2efe81 100644
--- a/django/core/validators.py
+++ b/django/core/validators.py
@@ -23,7 +23,7 @@ ip4_re = re.compile(r'^\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}$')
 phone_re = re.compile(r'^[A-PR-Y0-9]{3}-[A-PR-Y0-9]{3}-[A-PR-Y0-9]{4}$', re.IGNORECASE)
 url_re = re.compile(r'^http://\S+$')
 
-JING = '/usr/bin/jing'
+from django.conf.settings import JING_PATH
 
 class ValidationError(Exception):
     def __init__(self, message):
@@ -435,9 +435,9 @@ class RelaxNGCompact:
         fp = open(filename, 'w')
         fp.write(field_data)
         fp.close()
-        if not os.path.exists(JING):
-            raise Exception, "%s not found!" % JING
-        p = os.popen('%s -c %s %s' % (JING, self.schema_path, filename))
+        if not os.path.exists(JING_PATH):
+            raise Exception, "%s not found!" % JING_PATH
+        p = os.popen('%s -c %s %s' % (JING_PATH, self.schema_path, filename))
         errors = [line.strip() for line in p.readlines()]
         p.close()
         os.unlink(filename)