def get(self):
    """Formats the results from execute_query() for datastore.html.

    The only complex part of that process is calculating the pager variables
    to generate the Gooooogle pager at the bottom of the page.
    """
    result_set, total = self.execute_query()
    key_values = self.get_key_values(result_set)
    keys = key_values.keys()
    keys.sort()

    headers = []
    for key in keys:
      sample_value = key_values[key][0]
      headers.append({
        'name': key,
        'type': DataType.get(sample_value).name(),
      })

    entities = []
    edit_path = self.base_path() + DatastoreEditHandler.PATH
    for entity in result_set:
      attributes = []
      for key in keys:
        if entity.has_key(key):
          raw_value = entity[key]
          data_type = DataType.get(raw_value)
          value = data_type.format(raw_value)
          short_value = data_type.short_format(raw_value)
          additional_html = data_type.additional_short_value_html(raw_value)
        else:
          value = ''
          short_value = ''
          additional_html = ''
        attributes.append({
          'name': key,
          'value': value,
          'short_value': short_value,
          'additional_html': additional_html,
        })
      entities.append({
        'key': str(entity.key()),
        'key_name': entity.key().name(),
        'key_id': entity.key().id(),
        'shortened_key': str(entity.key())[:8] + '...',
        'attributes': attributes,
        'edit_uri': edit_path + '?key=' + str(entity.key()) + '&kind=' + urllib.quote(self.request.get('kind')) + '&next=' + urllib.quote(self.request.uri),
      })

    start = self.start()
    num = self.num()
    max_pager_links = 8
    current_page = start / num
    num_pages = int(math.ceil(total * 1.0 / num))
    page_start = max(math.floor(current_page - max_pager_links / 2), 0)
    page_end = min(page_start + max_pager_links, num_pages)

    pages = []
    for page in range(page_start + 1, page_end + 1):
      pages.append({
        'number': page,
        'start': (page - 1) * num,
      })
    current_page += 1

    in_production = self.in_production()
    if in_production:
      kinds = None
    else:
      kinds = self.get_kinds()

    values = {
      'request': self.request,
      'in_production': in_production,
      'kinds': kinds,
      'kind': self.request.get('kind'),
      'order': self.request.get('order'),
      'headers': headers,
      'entities': entities,
      'message': self.request.get('msg'),
      'pages': pages,
      'current_page': current_page,
      'num': num,
      'next_start': -1,
      'prev_start': -1,
      'start': start,
      'total': total,
      'start_base_url': self.filter_url(['kind', 'order', 'order_type',
                                         'num']),
      'order_base_url': self.filter_url(['kind', 'num']),
    }
    if current_page > 1:
      values['prev_start'] = int((current_page - 2) * num)
    if current_page < num_pages:
      values['next_start'] = int(current_page * num)

    self.generate('datastore.html', values)
dataset/ETHPy150Open CollabQ/CollabQ/.google_appengine/google/appengine/ext/admin/__init__.py/DatastoreQueryHandler.get/original