Improve usability of ogcserver debug mode by printing to new html response when in debug mode or when the QUERY_STRING is empty, signaling testing

This commit is contained in:
Dane Springmeyer 2009-02-12 01:28:57 +00:00
parent da9640c39d
commit e24b6f3654
4 changed files with 21 additions and 2 deletions

View file

@ -13,6 +13,7 @@ For a complete change history, see the SVN log.
Current Version (0.6.0-dev, SVN trunk):
---------------------------------------
- OGCServer: Enabled friendly html output when in debug mode (debug=1 in ogcserver.conf) (r899)
- Filter parsing: Allow numbers in the filter field name.
This allows for shapefiles with columns like '1970'.

View file

@ -356,6 +356,13 @@ class BaseExceptionHandler:
def getresponse(self, params):
code = ''
message = '\n'
if not params:
message = '''
<h2>Welcome to the Mapnik OGCServer.</h2>
<h3>Ready to accept map requests...</h5>
<h4>For more info see: <a href="http://trac.mapnik.org/wiki/OgcServer">trac.mapnik.org</a></h4>
'''
return self.htmlhandler('', message)
excinfo = exc_info()
if self.debug:
messagelist = format_exception(excinfo[0], excinfo[1], excinfo[2])
@ -365,10 +372,19 @@ class BaseExceptionHandler:
if isinstance(excinfo[1], OGCException) and len(excinfo[1].args) > 1:
code = excinfo[1].args[1]
exceptions = params.get('exceptions', None)
if self.debug:
return self.htmlhandler(code, message)
if not exceptions or not self.handlers.has_key(exceptions):
exceptions = self.defaulthandler
return self.handlers[exceptions](self, code, message, params)
def htmlhandler(self,code,message):
if code:
resp_text = '<h2>OGCServer Error:</h2><pre>%s</pre>\n<h3>Traceback:</h3><pre>%s</pre>\n' % (message, code)
else:
resp_text = message
return Response('text/html', resp_text)
def xmlhandler(self, code, message, params):
ogcexcetree = deepcopy(self.xmltemplate)
e = ogcexcetree.find(self.xpath)

View file

@ -224,6 +224,7 @@ class ExceptionHandler(BaseExceptionHandler):
handlers = {'application/vnd.ogc.se_xml': BaseExceptionHandler.xmlhandler,
'application/vnd.ogc.se_inimage': BaseExceptionHandler.inimagehandler,
'application/vnd.ogc.se_blank': BaseExceptionHandler.blankhandler}
'application/vnd.ogc.se_blank': BaseExceptionHandler.blankhandler,
'text/html': BaseExceptionHandler.htmlhandler}
defaulthandler = 'application/vnd.ogc.se_xml'

View file

@ -235,6 +235,7 @@ class ExceptionHandler(BaseExceptionHandler):
handlers = {'XML': BaseExceptionHandler.xmlhandler,
'INIMAGE': BaseExceptionHandler.inimagehandler,
'BLANK': BaseExceptionHandler.blankhandler}
'BLANK': BaseExceptionHandler.blankhandler,
'text/html': BaseExceptionHandler.htmlhandler}
defaulthandler = 'XML'