...

def read(self, table):
    """..."""
    # Table exists
    if table in self.by_id:
      return self.by_id[table].values()
    if table in self.cache:
      return self.cache[table]
    # Read table
    cls = self.FACTORIES[table]
    key = cls.KEY
    if key:
      if table not in self.by_id:
        self.by_id[table] = {}
      t = self.by_id[table]
      for item in self.iterread(table):
        t[item.get(key)] = item
      return t.values()
    if table not in self.cache:
      self.cache[table] = []
    t = self.cache[table]
    for item in self.iterread(table):
      t.append(item)
    return t