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)
class issue_get: @render_as('xml') def GET(self, selector): args = web.input() locale = str(args.get('locale')) if locale not in cc.license.locales(): locale = 'en' lclass = None if selector != 'software': if selector == 'publicdomain': selector = 'zero' lclass = cc.license.selectors.choose(selector) if not lclass: return api_exceptions.invalidclass() answers = support.build_answers_xml(lclass, args) try: support.validate_answers(lclass, answers) except AssertionError, e: return api_exceptions.invalidanswer() answers_dict = support.build_answers_dict(lclass, answers) issued_license = lclass.by_answers(answers_dict) work_dict = support.build_work_dict(issued_license, answers) work_xml = support.build_work_xml(issued_license, answers) try: return support.build_results_tree(issued_license, work_xml, work_dict, locale) except: return api_exceptions.pythonerr()
# issue the answers dict to the cc.license selector license = lclass.by_answers(answers_dict) locale = 'en' # check if a locale has been passed in answers if answers.xpath('/answers/locale'): locale = answers.xpath('/answers/locale')[0].text # verify that this is a valid locale if locale not in cc.license.locales(): locale = 'en' # just fallback, don't throw up work_dict = support.build_work_dict(license, answers) work_xml = support.build_work_xml(license, answers) try: return support.build_results_tree(license, work_xml, work_dict, locale) except: return api_exceptions.pythonerr() class issue_get: @render_as('xml') def GET(self, selector): args = web.input() locale = str(args.get('locale')) if locale not in cc.license.locales(): locale = 'en' try: assert selector != 'software' if selector == 'publicdomain': selector = 'zero'
# issue the answers dict to the cc.license selector license = lclass.by_answers(answers_dict) locale = 'en' # check if a locale has been passed in answers if answers.xpath('/answers/locale'): locale = answers.xpath('/answers/locale')[0].text # verify that this is a valid locale if locale not in cc.license.locales(): locale = 'en' # just fallback, don't throw up work_dict = support.build_work_dict(license, answers) work_xml = support.build_work_xml(license, answers) try: return support.build_results_tree(license, work_xml, work_dict, locale) except: return api_exceptions.pythonerr() class issue_get: @render_as('xml') def GET(self, selector): args = web.input() locale = str(args.get('locale')) if locale not in cc.license.locales(): locale = 'en' lclass = None if selector != 'software':