def handleGET(getBody, tableObj, models=None):
  if not tableObj:
    print("No results")
    return httpStatusCodes.NOT_FOUND, {'msg': "I need a table prototype"}

  tableObjManager = tableObj.objects
  objCount = tableObjManager.count()

  #========================= Population and Filtration here ========================#
  objProto = tableObj()
  bodyAttrs = getUserMutableFilters(objProto)

  dbObjs = tableObjManager
  nFiltrations = 0

  allowedFilters = captureUserMutableAttrs(bodyAttrs, getBody)

  # Finally we should also capture the id
  if 'id' in getBody:
    cId = None
    rId = getBody['id']
    if vFuncs.isUIntLike(rId):
      cId = rId
    elif type(rId) == 'list' and len(rId): # Query dicts trip out by providing u'id': [i]
      cId = rId[0]

    if cId is not None:
      allowedFilters += (('id', int(cId)),)

  selectAttrs = getBody.get(globVars.SELECT_KEY, None)
  selectKeys = None
  if selectAttrs:
    splitKeys = selectAttrs.split(',')
    # Always want id's
    if globVars.ID_KEY not in splitKeys:
      splitKeys.append(globVars.ID_KEY) 

    # Then convert to a tuple to allow dereferencing/unravelling of elements
    selectKeys = tuple(key for key in splitKeys if key in bodyAttrs)

    bodyAttrs = selectKeys

    # Populate only the requested attributes
    dbObjs = dbObjs.values(*selectKeys).all() if not allowedFilters\
                        else dbObjs.values(*selectKeys).filter(*allowedFilters)
  else:
    dbObjs = dbObjs.filter(*allowedFilters)

  #=================================================================================#
 
  #========================== Pagination and OffSets here ==========================#
  limit = getBody.get(globVars.LIMIT_KEY, None)

  if limit is None: 
    limit=0
  elif not vFuncs.isUIntLike(limit): # Only postive limits accepted
    limit = globVars.THRESHOLD_LIMIT
  else:  
    limit = int(limit)
  
  offSet = getBody.get(globVars.OFFSET_KEY, None)

  # Only accept positive offsets
  if not (offSet and vFuncs.isUIntLike(offSet)):
    offSet = globVars.THRESHOLD_OFFSET
  else:
    offSet = int(offSet)
 
  maxSize = dbObjs.count()
  if limit > maxSize:
    limit = maxSize 
  elif limit:
    limit += offSet

  #=============================== SORTING HERE ===================================#
  sortKey = getBody.get(globVars.SORT_KEY, None)
  sortKey, reverseTrue = translateSortKey(sortKey)
  if sortKey not in bodyAttrs: 
     sortKey = "-%s"%(globVars.ID_KEY)

  elif reverseTrue: 
     sortKey = (sortKey)%"-%s"
  
  #================================================================================#

  #============================== FORMAT HERE =====================================#
  formatKey = getBody.get(globVars.FORMAT_KEY, globVars.LONG_FMT_KEY)

  # Defining the default behaviour of the API to always return results
  # of 'long' as long format 'short' hasn't been defined
  # format=xong or format=zrer, should be interpreted as format=long
  connectedObjsBool = \
      re.search(formatKey, globVars.SHORT_FMT_KEY) == None

  data = list()

  if not limit:
    dbObjIterator = dbObjs.order_by(sortKey)[offSet:]
  else:
    dbObjIterator = dbObjs.order_by(sortKey)[offSet:limit]

  foreignVisited = {}
  connectedVisited = {}
  idMap = {}
  for dbObj in dbObjIterator:
    connmap = {}
    foreignKeyElems = getForeignKeyElems(dbObj, foreignVisited, models=models)
    if foreignKeyElems:
      connmap.update(foreignKeyElems)
    
    if connectedObjsBool: # A join requested
      connElems = getConnectedElems(dbObj, connectedVisited, models)
      if connElems:
        connmap.update(connElems)

    if hasattr(dbObj, 'id'):
      itemId = dbObj.id
    else:
      itemId = dbObj.get('id', None)
      if itemId is None:
        continue

    idMap[itemId] = connmap

  qs = dbObjIterator.values('id', *bodyAttrs)
  for item in qs:
     itId = item.get('id', -1)
     retrObj = idMap.get(itId, {})
     if retrObj:
       item.update(retrObj)

  data = [getSerializableElems(qi) for qi in qs]
  metaDict = dict(
    collectionCount=objCount, count=len(data),
    format=formatKey,sort=sortKey, limit=limit, offset=offSet
  )

  if selectKeys:
    metaDict[globVars.SELECT_KEY] = selectKeys

  return httpStatusCodes.OK, dict(meta=metaDict, data=data)
dataset/ETHPy150Open odeke-em/restAssured/api/crudAPI.py/handleGET/swapped operands of `%`