def _CreateTableConfig(self):
    """Creates a table config. Writes a valid name or an error message."""
    self._ValidateToken()
    name = self.request.get('tableName')
    master_bot = self.request.get('tableBots').splitlines()
    tests = self.request.get('tableTests').splitlines()
    table_layout = self.request.get('tableLayout')
    override = int(self.request.get('override'))
    user = users.get_current_user()
    if not name or not master_bot or not tests or not table_layout or not user:
      self.response.out.write(json.dumps({
          'error': 'Please fill out the form entirely.'
          }))
      return

    try:
      created_table = table_config.CreateTableConfig(
          name=name, bots=master_bot, tests=tests, layout=table_layout,
          username=user.email(), override=override)
    except table_config.BadRequestError as error:
      self.response.out.write(json.dumps({
          'error': error.message,
      }))
      logging.error('BadRequestError: %r', error.message)
      return


    if created_table:
      self.response.out.write(json.dumps({
          'name': name,
      }))
    else:
      self.response.out.write(json.dumps({
          'error': 'Could not create table.',
      }))
      logging.error('Could not create table.')