def create_or_update_client(client_mac_int, base_station, timestamp): client = get_client_with_mac(client_mac_int) if client is None: client = Client(mac=client_mac_int, first_seen=timestamp, last_seen=timestamp, base_stations=[base_station.key()]) else: client.last_seen = timestamp if base_station.key() not in client.base_stations: client.base_stations.append(base_station.key()) client.put() return client