diff --git a/isl/python/xslt_handler.wsgi b/isl/python/xslt_handler.wsgi index 573f99cc8d955cbe8a2d30b9c77d863c0ae5c4b9..771c7252464d060d6a00d05952058bb6ad7f8bef 100644 --- a/isl/python/xslt_handler.wsgi +++ b/isl/python/xslt_handler.wsgi @@ -45,19 +45,23 @@ class XsltHandler: Request handler - checks for 'type' and serves document using proper stylesheet. """ - def __init__(self, uri, paramd_uri, query_string): + def __init__(self, environ, uri, paramd_uri, query_string): """ Initialization - save request object """ + self.environ = environ self.uri = uri self.paramd_uri = paramd_uri self.query_string = query_string self.timeout = 2.0 self.got_timeout = False + def __log_error(self, error_string): + print(error_string, file=self.environ['wsgi.errors'])) + def isl_vu(self, context, args): if self.got_timeout: - #self.req.log_error('isl_vu: already got timeout - not doing request', apache.APLOG_WARNING) + self.__log_error('isl_vu: already got timeout - not doing request') return u'----' url = args[0] @@ -66,7 +70,7 @@ class XsltHandler: r = requests.get(url, timeout=self.timeout) if (r.status_code != 200): - #self.req.log_error('isl_vu status_code: %d' % r.status_code, apache.APLOG_WARNING) + self.__log_error('isl_vu status_code: %d' % r.status_code) return u'----' doc = etree.fromstring(r.content, parser) @@ -75,11 +79,10 @@ class XsltHandler: return vu except requests.exceptions.Timeout as e: - #self.req.log_error('isl_vu http timeout for url: %s' % url, apache.APLOG_WARNING) + self.__log_error('isl_vu http timeout for url: %s' % url) self.got_timeout = True except Exception as e: - #self.req.log_error('isl_vu url: %s get error: %s' % (url, str(e)), apache.APLOG_ERR) - pass + self.__log_error('isl_vu url: %s get error: %s' % (url, str(e))) return u'----' @@ -115,7 +118,7 @@ class XsltHandler: try: r = stylesheet(doc, uri = "'" + self.paramd_uri + "'") except Exception as e: - #self.req.log_error('content: stylesheet failed %s' % str(e), apache.APLOG_ERR) + self.__log_error('content: stylesheet failed %s' % str(e)) r = stylesheet.error_log return str(r) @@ -141,7 +144,7 @@ def application(environ, start_response): response_headers = [('Content-type', 'image/svg+xml')] start_response(status, response_headers) # paramd.uri should be set in Apache configuration file using SetEnv - h = XsltHandler(requested_path, environ['szarp.paramd.uri'], parse_qs(environ['QUERY_STRING'])) + h = XsltHandler(environ, requested_path, environ['szarp.paramd.uri'], parse_qs(environ['QUERY_STRING'])) ret = h.content() return [ret.encode('utf-8')] else: diff --git a/resources/xsltd/apache2-szarp b/resources/xsltd/apache2-szarp index 039438422b9b09b7393d3e69efc82f584a8e2b1b..cc435b150acd525c60a83c6bbdabe825541a1d89 100644 --- a/resources/xsltd/apache2-szarp +++ b/resources/xsltd/apache2-szarp @@ -20,7 +20,7 @@ NameVirtualHost *:8084 ExpiresDefault "access plus 9 seconds" #RewriteEngine On - + # Include user supplied configuration files IncludeOptional /etc/szarp/default/config/*.apache @@ -31,7 +31,7 @@ NameVirtualHost *:8084 # Everything else is forbidden #RewriteRule .* / [F] - + # 'Deny all' rule if something slips through above rewrite rule <Directory /> Require all denied @@ -42,7 +42,7 @@ NameVirtualHost *:8084 <Directory /etc/szarp/default/config/isl> Require all granted </Directory> - + # CGI directory ScriptAlias /cgi-bin /opt/szarp/bin <Directory /opt/szarp/bin> @@ -51,7 +51,7 @@ NameVirtualHost *:8084 Require all granted SetEnv szarp.paramd.uri "http://localhost:8081/" </Directory> - + ErrorLog /var/log/szarp/apache-error.log CustomLog /var/log/szarp/apache-access.log combined @@ -62,7 +62,7 @@ NameVirtualHost *:8084 LogLevel debug ScriptLog /var/log/szarp/apache-cgi.log </IfDefine> - + ServerSignature Off </VirtualHost>