def search(code, code_type='SBN', opere=None): item = None opere = opere and True or False if code_type.lower() == 'sbn': code_type = 'SBN' item = search_sbn(code, opere) else: code_type = 'VIAF' item = search_viaf(code) if item: if opere: return json_format(item, code_type, opere) else: return json_format(item, code_type)
def post_viafsbn(): code = request.forms.get('code').strip() item = None tipo = 'ERRORE' if re.match(REGEXP, code): tipo = 'SBN' code = code.replace('/', '\\') item = search_sbn(code) else: tipo = 'VIAF' item = search_viaf(code) if item: return template('viafsbn', item=item, tipo=tipo) else: return template('code_not_found', code=code, tipo=tipo)