def get_capabilities(self): """ Returns the capabilities of this service. Returns: pyramid.response.Response: The `capabilities` response. """ themes = list() for theme in Config.get_themes(): text = list() for lang in theme.text: text.append({ 'Language': lang, 'Text': theme.text[lang] }) themes.append({ 'Code': theme.code, 'Text': text }) capabilities = { u'GetCapabilitiesResponse': { u'topic': themes, u'municipality': [record.fosnr for record in self._municipality_reader.read()], u'flavour': Config.get_flavour(), u'language': Config.get_language(), u'crs': Config.get_crs() } } renderer_name = 'json' if self._is_json() else 'pyramid_oereb_capabilities_xml' response = render_to_response(renderer_name, capabilities, request=self._request) if self._is_json(): response.content_type = 'application/json; charset=UTF-8' return response
def get_capabilities(self): """ Returns the capabilities of this service. Returns: pyramid.response.Response: The `capabilities` response. """ params = Parameter('json' if self._is_json() else 'xml') supported_languages = Config.get_language() themes = list() for theme in Config.get_themes(): text = list() for lang in theme.text: if lang in supported_languages: text.append({'Language': lang, 'Text': theme.text[lang]}) themes.append({'Code': theme.code, 'Text': text}) capabilities = { u'GetCapabilitiesResponse': { u'topic': themes, u'municipality': [ record.fosnr for record in self._municipality_reader.read(params) ], u'flavour': Config.get_flavour(), u'language': supported_languages, u'crs': [Config.get_crs()] } } # Try - catch for backward compatibility with old specification. try: output_format = self.__validate_format_param__(['xml', 'json']) except HTTPBadRequest: output_format = None log.warning( 'Deprecated way to specify the format. Use "/capabilities/{format}" instead' ) renderer_name = 'json' if output_format == 'json' or self._is_json( ) else 'pyramid_oereb_capabilities_xml' # noqa: E501 response = render_to_response(renderer_name, capabilities, request=self._request) if self._is_json(): response.content_type = 'application/json; charset=UTF-8' response.extras = OerebStats(service='GetCapabilities', output_format=output_format) return response
def get_capabilities(self): """ Returns the capabilities of this service. Returns: pyramid.response.Response: The `capabilities` response. """ output_format = self.__validate_format_param__(self._DEFAULT_FORMATS) params = Parameter(output_format) supported_languages = Config.get_language() themes = list() for theme in Config.get_themes(): text = list() for lang in theme.title: if lang in supported_languages: text.append({'Language': lang, 'Text': theme.title[lang]}) themes.append({'Code': theme.code, 'Text': text}) processor = create_processor() capabilities = { u'GetCapabilitiesResponse': { u'topic': themes, u'municipality': [ record.fosnr for record in processor.municipality_reader.read(params) ], u'flavour': Config.get_flavour(), u'language': supported_languages, u'crs': [Config.get_crs()] } } renderer_name = 'json' if output_format == 'json' else 'pyramid_oereb_capabilities_xml' # noqa: E501 response = render_to_response(renderer_name, capabilities, request=self._request) if output_format == 'json': response.content_type = 'application/json; charset=UTF-8' # response.extras = OerebStats(service='GetCapabilities', output_format=output_format) return response