Changeset 521
- Timestamp:
- 10/18/06 16:34:28
- Files:
-
- OWSLib/trunk/owslib/wfs.py (modified) (2 diffs)
- OWSLib/trunk/tests/MapServerWFSFeature.txt (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
OWSLib/trunk/owslib/wfs.py
r520 r521 22 22 23 23 import cgi 24 from urllib import urlencode, urlopen 24 from cStringIO import StringIO 25 import sys 26 from urllib import urlencode 27 from urllib2 import urlopen 25 28 26 29 from etree import etree … … 111 114 else: 112 115 u = urlopen(base_url + data) 113 116 114 117 # check for service exceptions, rewrap, and return 115 return u 116 117 118 # We're going to assume that anything with a content-length > 32k 119 # is data. We'll check anything smaller. 120 if int(u.info()['Content-Length']) < 32000: 121 data = u.read() 122 tree = etree.fromstring(data) 123 if tree.tag == "{%s}ServiceExceptionReport" % OGC_NAMESPACE: 124 se = tree.find(nspath('ServiceException', OGC_NAMESPACE)) 125 raise ServiceException, str(se.text).strip() 126 else: 127 return StringIO(data) 128 else: 129 return u 130 131 118 132 class ServiceMetadata(object): 119 133 """Abstraction for WFS metadata. OWSLib/trunk/tests/MapServerWFSFeature.txt
r520 r521 7 7 8 8 >>> wfs = WebFeatureService('http://www.bsc-eoc.org/cgi-bin/bsc_ows.asp?', version='1.0.0') 9 >>> xml = wfs.getfeature(typename=['IBA'], maxfeatures=5).read()10 >>> xml.find('<wfs:FeatureCollection') > 09 >>> response = wfs.getfeature(typename=['IBA'], maxfeatures=5) 10 >>> response.read().find('<wfs:FeatureCollection') > 0 11 11 True 12 12 13 Handle service exception 14 15 >>> response = wfs.getfeature(typename=['totally bogus'], maxfeatures=5) 16 Traceback (most recent call last): 17 ... 18 ServiceException: msWFSGetFeature(): WFS server error. TYPENAME 'totally bogus' doesn't exist in this server. Please check the capabilities and reformulate your request. 19
