except BadValueError: logging.error("Address not added for venue %s with address json '%s'" % (j_venue['id'], j_venue['address'])) if 'cross_street' in j_venue: uservenue.cross_street = j_venue['cross_street'] # if 'city' in j_venue: # uservenue.city = j_venue['city'] if 'state' in j_venue: uservenue.state = j_venue['state'] if 'zip' in j_venue: uservenue.zipcode = j_venue['zip'] if 'phone' in j_venue: uservenue.phone = j_venue['phone'] uservenue.last_updated = datetime.strptime(checkin['created'], "%a, %d %b %y %H:%M:%S +0000") #WARNING last_updated is confusing and should be last_checkin_at if datetime.now() < uservenue.last_updated + timedelta(hours=12): continue #WARNING last_updated is confusing and should be last_checkin_at uservenue.checkin_list.append(checkin['id']) uservenue.put() userinfo.checkin_count += 1 if checkin['id'] > userinfo.last_checkin: userinfo.last_checkin = checkin['id'] # because the checkins are ordered with most recent first! userinfo.put() num_added += 1 # else: # there's nothing we can do without a venue id or a lat and a lng # logging.info("Problematic j_venue: " + str(j_venue)) # else: # logging.info("No venue in checkin: " + str(checkin)) except KeyError: logging.error("There was a KeyError when processing the response: " + response.content) raise return num_added def fetch_and_store_checkins_initial(userinfo): #logging.info("about to fetch, userinfo.last_checkin = %d" % (userinfo.last_checkin))