@@ -145,23 +145,25 @@ def getdomain(self, dname, dtype='parameter'):
145145 etree .SubElement (node0 , util .nspath_eval ('csw30:%s' % dtypename , namespaces )).text = dname
146146
147147 self .request = node0
148+ try : # getdomain operation is optional on CSW3, return empty if failing
149+ self ._invoke ()
148150
149- self ._invoke ()
150-
151- if self .exceptionreport is None :
152- self .results = {}
151+ if self .exceptionreport is None :
152+ self .results = {}
153153
154- val = self ._exml .find (util .nspath_eval ('csw30:DomainValues' , namespaces )).attrib .get ('type' )
155- self .results ['type' ] = util .testXMLValue (val , True )
154+ val = self ._exml .find (util .nspath_eval ('csw30:DomainValues' , namespaces )).attrib .get ('type' )
155+ self .results ['type' ] = util .testXMLValue (val , True )
156156
157- val = self ._exml .find (util .nspath_eval ('csw30:DomainValues/csw30:%s' % dtypename , namespaces ))
158- self .results [dtype ] = util .testXMLValue (val )
157+ val = self ._exml .find (util .nspath_eval ('csw30:DomainValues/csw30:%s' % dtypename , namespaces ))
158+ self .results [dtype ] = util .testXMLValue (val )
159159
160- # get the list of values associated with the Domain
161- self .results ['values' ] = []
160+ # get the list of values associated with the Domain
161+ self .results ['values' ] = []
162162
163- for f in self ._exml .findall (util .nspath_eval ('csw30:DomainValues/csw30:ListOfValues/csw30:Value' , namespaces )): # noqa
164- self .results ['values' ].append (util .testXMLValue (f ))
163+ for f in self ._exml .findall (util .nspath_eval ('csw30:DomainValues/csw30:ListOfValues/csw30:Value' , namespaces )): # noqa
164+ self .results ['values' ].append (util .testXMLValue (f ))
165+ except Exception :
166+ self .results = {'values' : []}
165167
166168 def getrecordbyid (self , id = [], esn = 'full' , outputschema = namespaces ['csw30' ], format = outputformat ):
167169 """
@@ -557,15 +559,16 @@ def _invoke(self):
557559 post_verbs = [x for x in op .methods if x .get ('type' ).lower () == 'post' ]
558560 if len (post_verbs ) > 1 :
559561 # Filter by constraints. We must match a PostEncoding of "XML"
562+ found_xml = False
560563 for pv in post_verbs :
561564 for const in pv .get ('constraints' ):
562565 if const .name .lower () == 'postencoding' :
563566 values = [v .lower () for v in const .values ]
564567 if 'xml' in values :
565568 request_url = pv .get ('url' )
569+ found_xml = True
566570 break
567- else :
568- # Well, just use the first one.
571+ if not found_xml : # Well, just use the first one.
569572 request_url = post_verbs [0 ].get ('url' )
570573 elif len (post_verbs ) == 1 :
571574 request_url = post_verbs [0 ].get ('url' )
0 commit comments