Hi Angus,

Glad to hear you are finding OWSLib (and Shapely) useful.

As you've found, you can get to the XML in a roundabout way using the 
_capabilities attribute but I agree not everyone wants an elementtree 
object!

Also as it says in the comments in the code, the current getcapabilities 
method is actually redundant now for normal usage (the capabilites doc 
is parsed during __init__ ) so this method should be removed. Also it's 
not very efficient  - you're right.

Okay, to your proposals:

Instead of adding another capabilities-like method to get the XML we 
could just expose a new attribute:

        wms.capabilitiesXML

Would that do? This would be useful for all services actually.

In terms of the service exception, I'm not really keen to expose this as 
an attribute or method as it should really be handled as an exception 
(rather than being seen as a property of the wms object).

So would it be better to just modify the ServiceException raised to 
return the full raw XML string?

I think the original idea was to be 'user friendly' and return the 
appropriate text, but I can see it might be useful to return everything.

Currently if you just want to read the error text you can do:

try:
     img = wms.getmap(layers=['global_mosaic'],styles=['visual_bright'], 
         srs='EPSG:4326', bbox=(-112, 36, -106, 41), size=(300, 250), 
   format='image/ banana', transparent=True)
except ServiceException, myerror:
     print myerror  #will currently print the text "The format 
"image/banana" is invalid"


So we could modify the ServiceException handling so that it just returns 
raw XML. Then you can do what you want with it. What do you think?

Cheers,

Dom




On 25/02/10 05:44, Angus Dickey wrote:
> Hello all,
>
> I have been trying out OWSLib (and Shapely) over the past couple weeks and 
> would like to say good work to everyone involved in creating/maintaining it.
>
> I am using OWSLib to simplify making WMS requests in a wxpython app. I was 
> just curious if there is a way I am overlooking to have WebMapService return 
> the raw capabilities XML and raw exception XML?
>
>  From what I can see the "getcapabilities" method will return XML as a file 
> object but makes a new http request for the data even when it already exists. 
> As far as getting the raw exception XML; once an exception is raised the 
> capabilites XML (or image if using "getmap") will always be None, so the 
> exception XML can't be accessed this way (which really makes sense anyway).
>
> I want to have this info so I can let the user view it if they want to so I 
> modified wms.py (rev. 1539) a bit (attached). My question is if anyone can 
> think of a reason not to do this? And if something like this can be added to 
> OWSLib as a patch?
>
> There is probably a better way to do this but I just added a method to return 
> the raw xml if WebMapService has it, and a method to return the last 
> "application/vnd.ogc.se_xml" exception.
>
> Anyway,
>
> Thanks for any insight.
>
> ~Angus
>
>
>        __________________________________________________________________
> The new Internet Explorer® 8 - Faster, safer, easier.  Optimized for Yahoo!  
> Get it Now for Free! at http://downloads.yahoo.com/ca/internetexplorer/
>
>
>
> _______________________________________________
> Community mailing list
> [email protected]
> http://lists.gispython.org/mailman/listinfo/community

_______________________________________________
Community mailing list
[email protected]
http://lists.gispython.org/mailman/listinfo/community

Reply via email to