def POST(self, selector): lclass = None if selector != 'software': if selector == 'publicdomain': selector = 'zero' lclass = cc.license.selectors.choose(selector) if not lclass: return api_exceptions.invalidclass() answers_xml = web.input().get('answers') if not answers_xml: return api_exceptions.missingparam('answers') try: if selector == 'zero': answers_xml = answers_xml.replace( '<license-publicdomain>', '<license-zero>').replace('</license-publicdomain>', '</license-zero>') # parse the answers argument into an xml tree answers = ET.parse(StringIO(answers_xml)) except ET.XMLSyntaxError, e: return api_exceptions.invalidanswer()
def POST(self, selector): try: assert selector != 'software' if selector == 'publicdomain': lclass = cc.license.selectors.choose('zero') else: lclass = cc.license.selectors.choose(selector) except: return api_exceptions.invalidclass() if not web.input().get('answers'): return api_exceptions.missingparam('answers') try: answers_xml = web.input().get('answers') if selector == 'publicdomain': answers_xml = answers_xml.replace( '<license-publicdomain>', '<license-zero>').replace( '</license-publicdomain>', '</license-zero>') # parse the answers argument into an xml tree answers = ET.parse(StringIO(answers_xml)) except ET.XMLSyntaxError, e: return api_exceptions.invalidanswer()
def GET(self, locale=None, license_uri=None): """ Accepts a license uri as an argument and will return the RDF and RDFa of a licnsee """ locale = locale or web.input().get('locale', 'en') license_uri = license_uri or web.input().get('license-uri') if not license_uri: return api_exceptions.missingparam('license-uri') license = cc.license.by_uri(str(license_uri)) if not license: return api_exceptions.invaliduri() return support.build_results_tree(license, locale=locale)
def GET(self, locale=None, license_uri=None): """ Accepts a license uri as an argument and will return the RDF and RDFa of a licnsee """ locale = locale or web.input().get('locale', 'en') license_uri = license_uri or web.input().get('license-uri') if not license_uri: return api_exceptions.missingparam('license-uri') try: l = cc.license.by_uri(str(license_uri)) except cc.license.CCLicenseError: return api_exceptions.invaliduri() return support.build_results_tree(l, locale=locale)