From: Diane Trout Date: Tue, 17 Dec 2013 19:11:04 +0000 (-0800) Subject: Move loading DTD into a function as the call caused a hang when loaded into wsgi X-Git-Url: http://woldlab.caltech.edu/gitweb/?p=htsworkflow.git;a=commitdiff_plain;h=a2494bb119fc60e1b024b439249cb00280457d04 Move loading DTD into a function as the call caused a hang when loaded into wsgi --- diff --git a/htsworkflow/util/ethelp.py b/htsworkflow/util/ethelp.py index 7398963..f2f3e01 100644 --- a/htsworkflow/util/ethelp.py +++ b/htsworkflow/util/ethelp.py @@ -5,11 +5,6 @@ import os LOGGER = logging.getLogger(__name__) import lxml.etree -try: - XHTML_RDF_DTD = lxml.etree.DTD(external_id='-//W3C//DTD XHTML+RDFa 1.0//EN') -except lxml.etree.DTDParseError as e: - XHTML_RDF_DTD = None - LOGGER.warn("Unable to load XHTML DTD %s" % (str(e),)) def indent(elem, level=0): """ @@ -49,8 +44,11 @@ def validate_xhtml(html, base_url='http://localhost'): Returns True if it passed validation and False if it fails. """ - if XHTML_RDF_DTD is None: - return None + try: + XHTML_RDF_DTD = lxml.etree.DTD(external_id='-//W3C//DTD XHTML+RDFa 1.0//EN') + except lxml.etree.DTDParseError as e: + LOGGER.warn("Unable to load XHTML DTD %s" % (str(e),)) + return try: root = lxml.etree.fromstring(html, base_url=base_url)