def get(self):
    entity_key = self.request.get('key')
    if entity_key:
      key_instance = datastore.Key(entity_key)
      entity_key_name = key_instance.name()
      entity_key_id = key_instance.id()
      parent_key = key_instance.parent()
      kind = key_instance.kind()
      entity = datastore.Get(key_instance)
      sample_entities = [entity]
    else:
      kind = self.request.get('kind')
      sample_entities = self.execute_query()[0]

    if len(sample_entities) < 1:
      next_uri = self.request.get('next')
      kind_param = 'kind=%s' % kind
      if not kind_param in next_uri:
        if next_uri in '?':
          next_uri += '&' + kind_param
        else:
          next_uri += '?' + kind_param
      self.redirect(next_uri)
      return

    if not entity_key:
      key_instance = None
      entity_key_name = None
      entity_key_id = None
      parent_key = None
      entity = None

    if parent_key:
      parent_kind = parent_key.kind()
      parent_key_string = PseudoBreadcrumbs(parent_key)
    else:
      parent_kind = None
      parent_key_string = None

    fields = []
    key_values = self.get_key_values(sample_entities)
    for key, sample_values in key_values.iteritems():
      if entity and entity.has_key(key):
        data_type = DataType.get(entity[key])
      else:
        data_type = DataType.get(sample_values[0])
      name = data_type.name() + "|" + key
      if entity and entity.has_key(key):
        value = entity[key]
      else:
        value = None
      field = data_type.input_field(name, value, sample_values)
      fields.append((key, data_type.name(), field))

    self.generate('datastore_edit.html', {
      'kind': kind,
      'key': entity_key,
      'key_name': entity_key_name,
      'key_id': entity_key_id,
      'fields': fields,
      'focus': self.request.get('focus'),
      'next': self.request.get('next'),
      'parent_key': parent_key,
      'parent_kind': parent_kind,
      'parent_key_string': parent_key_string,
    })
dataset/ETHPy150Open CollabQ/CollabQ/.google_appengine/google/appengine/ext/admin/__init__.py/DatastoreEditHandler.get/swapped operands of `in`