source: cows/trunk/cows/pylons/templates/exception_report.kid @ 3364

Subversion URL: http://proj.badc.rl.ac.uk/svn/ndg/cows/trunk/cows/pylons/templates/exception_report.kid@4412
Revision 3364, 1.0 KB checked in by spascoe, 12 years ago (diff)

Moving exception template to ows_common

Line 
1<?xml version="1.0" encoding="UTF-8"?>
2<?python
3"""
4A OWS exception report.
5
6@param report: An ows_common.exception_report object
7"""
8
9def hide_optionals(attrDict, optionals=None):
10    """
11    Returns a copy of attrDict where any value which is None and in optionals is removed.
12
13    If optionals=None all keys are considered optional.
14
15    @todo: move this to a utils module
16    """
17    od = {}
18    for key, value in attrDict.items():
19        if (value is not None) or (optionals and key not in optionals):
20            od[key] = value
21
22    return od
23?>
24<ExceptionReport xmlns="http://www.opengis.net/ows"
25                 xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
26                 xmlns:py="http://purl.org/kid/ns#"
27                 xsi:schemaLocation="http://www.opengis.net/ows owsExceptionReport.xsd"
28                 version="${report.version}"
29                 py:attrs="hide_optionals(dict(language=report.lang))">
30<Exception py:for="e in report.exceptions"
31           py:content="e.text"
32           exceptionCode="${e.code}"
33           py:attrs="hide_optionals(dict(locator=e.locator))"/>
34</ExceptionReport>
35                 
Note: See TracBrowser for help on using the repository browser.