def oai_error(argd, errors): """ Return a well-formatted OAI-PMH error """ out = """<?xml version="1.0" encoding="UTF-8"?> <OAI-PMH xmlns="http://www.openarchives.org/OAI/2.0/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.openarchives.org/OAI/2.0/ http://www.openarchives.org/OAI/2.0/OAI-PMH.xsd">""" out += X.responseDate()(get_utc_now()) for error_code, error_msg in errors: assert(error_code in CFG_ERRORS) if error_code in ("badArgument", "badVerb"): out += X.request()(oai_get_request_url()) break else: ## There are no badArgument or badVerb errors so we can ## return the whole request information out += X.request(**argd)(oai_get_request_url()) for error_code, error_msg in errors: if error_msg is None: error_msg = CFG_ERRORS[error_code] else: error_msg = "%s %s" % (CFG_ERRORS[error_code], error_msg) out += X.error(code=error_code)(error_msg) out += "</OAI-PMH>" return out
def oai_error(argd, errors): """ Return a well-formatted OAI-PMH error """ out = """<?xml version="1.0" encoding="UTF-8"?> <OAI-PMH xmlns="http://www.openarchives.org/OAI/2.0/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.openarchives.org/OAI/2.0/ http://www.openarchives.org/OAI/2.0/OAI-PMH.xsd">""" out += X.responseDate()(get_utc_now()) for error_code, error_msg in errors: assert (error_code in CFG_ERRORS) if error_code in ("badArgument", "badVerb"): out += X.request()(oai_get_request_url()) break else: ## There are no badArgument or badVerb errors so we can ## return the whole request information out += X.request(**argd)(oai_get_request_url()) for error_code, error_msg in errors: if error_msg is None: error_msg = CFG_ERRORS[error_code] else: error_msg = "%s %s" % (CFG_ERRORS[error_code], error_msg) out += X.error(code=error_code)(error_msg) out += "</OAI-PMH>" return out