def s3_get_foreign_key(field, m2m=True):
 ftype = str(field.type)
 multiple = False
 if (ftype[:9] == 'reference'):
  key = ftype[10:]
 elif (m2m and (ftype[:14] == 'list:reference')):
  key = ftype[15:]
  multiple = True
 else:
  key = current.s3db.virtual_reference(field)
  if (not key):
   return (None, None, None)
 if ('.' in key):
  (rtablename, key) = key.split('.')
 else:
  rtablename = key
  rtable = current.s3db.table(rtablename)
  if rtable:
   key = rtable._id.name
  else:
   key = None
 return (rtablename, key, multiple)

def s3_get_foreign_key ( field , m2m = True ) : ftype = str ( field . type ) multiple = False if ( ftype [ : 9 ] == 'reference' ) : key = ftype [ 10 : ] elif ( m2m and ( ftype [ : 14 ] == 'list:reference' ) ) : key = ftype [ 15 : ] multiple = True else : key = current . s3db . virtual_reference ( field ) if ( not key ) : return ( None , None , None ) if ( '.' in key ) : ( rtablename , key ) = key . split ( '.' ) else : rtablename = key rtable = current . s3db . table ( rtablename ) if rtable : key = rtable . _id . name else : key = None return ( rtablename , key , multiple )
resolve a field type into the name of the referenced table .