def home_view(request): if request.current_route_path() == '/': menu_items = [] for r in range(len(NAMEFAM)): menu_items.append( [str(NAMEFAM['namekey'][r]), str(NAMEFAM['human_namekey'][r])] ) return {'menu_items': menu_items} try: name = request.matchdict['name'] except KeyError: return {} if 'HTTP_X_REQUESTED_WITH' in request.environ: if query_name_or_fam(gb, name) is None: return {'error': 'Ba-a-a-a-a-a-a-a-a-ad query. Try again.'} else: fam_df, namekey, placename = query_name_or_fam(gb, name) if namekey is None: return {'fam_df': fam_df.fillna(0), 'name': placename, 'message': 'Does not belong to a known family of names.'} namefam_dict = query_namefam_table(namekey) return {'fam_df': fam_df.fillna(0), 'namefam_dict': namefam_dict, 'name': placename}
def dropdown_view(request): try: namekey = request.matchdict['namekey'] except KeyError: return {} if 'HTTP_X_REQUESTED_WITH' in request.environ: fam_df, namekey, placename = get_fam(gb, namekey) namefam_dict = query_namefam_table(namekey) return {'fam_df': fam_df.fillna(0), 'namefam_dict': namefam_dict}