def account_ids_by_ip(ip, after=None, before=None, limit=1000):
 ips = tup(ip)
 results = []
 flattened_accounts = {}
 for ip in ips:
  if (before and (not after)):
   account_ip = AccountsByIP.get(ip, column_start=before, column_count=(limit + 1), column_reversed=False)
   account_ip = sorted(account_ip, reverse=True)
  else:
   account_ip = AccountsByIP.get(ip, column_start=after, column_count=limit)
  flattened_account_ip = [j for i in account_ip for j in i.iteritems()]
  flattened_accounts[ip] = flattened_account_ip
 for (ip, flattened_account_ip) in flattened_accounts.iteritems():
  for (last_visit, account) in flattened_account_ip:
   results.append((account, last_visit, [ip]))
 return results

def account_ids_by_ip ( ip , after = None , before = None , limit = 1000 ) : ips = tup ( ip ) results = [ ] flattened_accounts = { } for ip in ips : if ( before and ( not after ) ) : account_ip = AccountsByIP . get ( ip , column_start = before , column_count = ( limit + 1 ) , column_reversed = False ) account_ip = sorted ( account_ip , reverse = True ) else : account_ip = AccountsByIP . get ( ip , column_start = after , column_count = limit ) flattened_account_ip = [ j for i in account_ip for j in i . iteritems ( ) ] flattened_accounts [ ip ] = flattened_account_ip for ( ip , flattened_account_ip ) in flattened_accounts . iteritems ( ) : for ( last_visit , account ) in flattened_account_ip : results . append ( ( account , last_visit , [ ip ] ) ) return results
get a list of account ids that an ip has accessed .