def app_xml(app_id): try: data = adaptor.load_data(app_id) url = data['url'] contents = urllib2.urlopen(url).read() # If the user hasn't clicked on "Save" yet, do not replace configuration script if data.get('configuration_name'): contents = replace_default_configuration_script(contents, url_for('.configuration', app_id = app_id, _external = True)) contents = inject_absolute_urls(contents, url) xmldoc = minidom.parseString(contents) inject_original_url_in_xmldoc(xmldoc, url) inject_absolute_locales_in_xmldoc(xmldoc, url) contents = xmldoc.toprettyxml() except Exception as e: traceback.print_exc() # TODO: some bootstrap magic return "Could not convert the application. %s" % str(e) else: return Response(contents, mimetype='text/xml')
def app_xml(app_id): try: data = adaptor.load_data(app_id) url = data['url'] contents = urllib2.urlopen(url).read() # If the user hasn't clicked on "Save" yet, do not replace configuration script if data.get('configuration_name'): contents = replace_default_configuration_script( contents, url_for('.configuration', app_id=app_id, _external=True)) contents = inject_absolute_urls(contents, url) xmldoc = minidom.parseString(contents) inject_original_url_in_xmldoc(xmldoc, url) inject_absolute_locales_in_xmldoc(xmldoc, url) contents = xmldoc.toprettyxml() except Exception as e: traceback.print_exc() # TODO: some bootstrap magic return "Could not convert the application. %s" % str(e) else: return Response(contents, mimetype='text/xml')
def _test_injection(self, original, expected): obtained = inject_absolute_urls(original, URL) self.assertEquals(obtained, expected)