def uservenue_factory(userinfo_param, j_venue_param, checkin_guid_list_param, checkin_list_param, is_unique_param):
   new_uservenue = UserVenue(parent=userinfo_param, location = db.GeoPt(j_venue_param['location']['lat'], j_venue_param['location']['lng']))
   j_venue_param_loc = j_venue_param['location']
   new_uservenue.update_location()
   new_uservenue.user = userinfo_param.user
   new_uservenue.venue_guid     = str(j_venue_param['id'])
   if 'name' in j_venue_param:
     new_uservenue.name         = j_venue_param['name']
   if 'address' in j_venue_param_loc:
     new_uservenue.address      = j_venue_param_loc['address'].replace('\n', ' ').replace('\r', ' ')
   if 'cross_street' in j_venue_param_loc:
     new_uservenue.cross_street = j_venue_param_loc['cross_street']
   if 'state' in j_venue_param_loc:
     new_uservenue.state        = j_venue_param_loc['state']
   if 'zip' in j_venue_param_loc:
     new_uservenue.zipcode      = j_venue_param_loc['zip']
   if 'phone' in j_venue_param:
     new_uservenue.phone        = j_venue_param['phone']
   new_uservenue.has_parent = True
   new_uservenue.is_unique = is_unique_param 
   new_uservenue.checkin_list = checkin_list_param
   new_uservenue.checkin_guid_list = checkin_guid_list_param
   if not new_uservenue.checkin_guid_list or len(new_uservenue.checkin_guid_list) is 0:
     new_uservenue.checkin_guid_list = [str(checkin_id) for checkin_id in new_uservenue.checkin_list]
   return new_uservenue
 uservenue = UserVenue.all().filter('user ='******'venue_id =', j_venue['id']).get()
 if uservenue == None:
   uservenue = UserVenue(location = db.GeoPt(j_venue['geolat'], j_venue['geolong']))
   uservenue.update_location()
   uservenue.user = userinfo.user
   userinfo.venue_count = userinfo.venue_count + 1
   uservenue.venue_id       = int(j_venue['id'])
   if 'name' in j_venue:
     uservenue.name         = j_venue['name']
   try:
     if 'address' in j_venue:
       uservenue.address      = j_venue['address']
   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()