Hi Dom
The openURL function in the utils module appears to be expecting unqualified
GET/POST, but the getfeature method of wf100.py is being called with the
qualified strings
Even if I hijack the method and pass 'Post' or 'Get' to openURL, I still
get:
File "<stdin>", line 1, in <module>
File
"/usr/local/lib/python2.6/dist-packages/OWSLib-0.3.2beta-py2.6.egg/owslib/feature/wfs100.py",
line 203, in getfeature
length = int(u.info()['Content-Length'])
AttributeError: 'RereadableURL' object has no attribute 'info'
... Which is a result of the old length tests, now carried out in openURL,
so:
after
u = openURL(base_url, data, unqualified_method) # as you suggest, and
method hijacked
commenting all the subsequent code and replacing with:
return u
allows it to return a GetFeature response
The end result is that it appears as if a few changes will allow the
getfeature method of WFS to work more like the WMS/WCS modules
Regards
Graeme
On 14/10/10 13:55, Dominic Lowe wrote:
*>> in the utils directory
>I mean in the owslib.util module
>
>On 14/10/10 13:51, Dominic Lowe wrote:
>> Graeme,
>>
>> I haven't experimented much with the WFS code, but we've had this
>> problem (or similar) with WMS and WCS in the past. There is actually a
>> (fairly new) method in the utils directory called 'openURL' which owslib
>> should now use for opening all urls as it does various checks for things
>> like question marks. However, it looks like we didn't get as far as
>> migrating the WFS code to use this new method.
>>
>> If you have the time could you try and replace your proposed fix with
>> the following and see if that also fixes the problem in your case:
>>
>> from owslib.util import openURL
>> u = openURL(base_url, data, method)
>>
>> Much appreciated,
>>
>> Dom
>>
>>
>>
>> On 14/10/10 11:59, Graeme McFerren wrote:
>>> I am having a bit of trouble with attempting a GetFeature Request
>>> against a Geoserver 2.0.1 WFS, using OWSLib Trunk on Ubuntu 10.04/
>>> Python 2.6.5
>>>
>>> The following lines in OWSLib/trunk/owslib/feature/wfs100.py seem to be
>>> the problem:
>>>
>>> 185 if method == 'Post':
>>> 186 u = urlopen(base_url, data=data)
>>> 187 else:
>>> 188 u = urlopen(base_url + data)
>>>
>>> Whether GETing or POSTing, the URL's are mangled:
>>>
>>> e.g GET -> GET
>>>
/geoserver/wfs?request=GetFeatureservice=WFS&maxfeatures=5&propertyname=%2A&request=GetFeature&typename=openafis%3Akruger_burn_blocks&version=1.0.0
>>>
>>>
>>> e.g. POST -> GET
>>>
/geoserver/wfs&service=WFS&maxfeatures=5&propertyname=%2A&request=GetFeature&typename=openafis%3Akruger_burn_blocks&version=1.0.0
>>>
>>>
>>> and an error is caused (Service Exception in GET case and HTTP 404 in
>>> the case of POST)
>>>
>>> For GET, reason seems to be that there is a missing ampersand between
>>> request=GetFeatureservice=WFS
>>>
>>> For POST, reason seems to be that the GetFeature method parameter
>>> expects a full '{http://www.opengis.net/wfs}Post' string, yet in Line
>>> 185, the unqualified string is tested for, is never found and falls
>>> through to generating a faulty GET request
>>>
>>> This statement hack seems to fix the problem for me:
>>>
>>> if method == '{http://www.opengis.net/wfs}Post':
>>> u = urlopen(base_url, data=data)
>>> else:
>>> u = urlopen(base_url + '&' + data)
>>>
>>> Has this kind of thing been noticed before?
>>>
>>> Regards
>>> Graeme McFerren
>>>
>>>
>>>
>>> _______________________________________________
>>> Community mailing list
>>> Community at lists.gispython.org
>>> http://lists.gispython.org/mailman/listinfo/community
>>
>> _______________________________________________
>> Community mailing list
>> Community at lists.gispython.org
>> http://lists.gispython.org/mailman/listinfo/community*
_______________________________________________
Community mailing list
[email protected]
http://lists.gispython.org/mailman/listinfo/community