Exemplo n.º 1
0
def clear(*args, **kwargs):
    """Removes all entities from the datastore.
  """

    # there no explicit ranker model anywhere, so make one for
    # our own convenience to delete all rankers
    class ranker(db.Model):
        """ranker model used with ranklist module.
    """
        pass

    # TODO(dbentley): If there are more than 1000 instances of any model,
    # this method will not clear all instances.  Instead, it should continually
    # call .all(), delete all those, and loop until .all() is empty.
    entities = itertools.chain(*[
        Notification.all(),
        GSoCMentor.all(),
        GHOPMentor.all(),
        GSoCStudent.all(),
        GHOPStudent.all(),
        Survey.all(),
        SurveyContent.all(),
        SurveyRecord.all(),
        GSoCOrgAdmin.all(),
        GHOPOrgAdmin.all(),
        ranker.all(),
        RankerRoot.all(),
        StudentProposal.all(),
        GSoCOrganization.all(),
        GHOPOrganization.all(),
        OrgApplication.all(),
        GSoCTimeline.all(),
        GHOPTimeline.all(),
        GSoCProgram.all(),
        GHOPProgram.all(),
        Host.all(),
        Sponsor.all(),
        User.all(),
        Site.all(),
        Document.all(),
    ])

    try:
        for entity in entities:
            entity.delete()
    except db.Timeout:
        return http.HttpResponseRedirect('#')
    # pylint: disable-msg=E1101
    memcache.flush_all()

    return http.HttpResponse('Done')
Exemplo n.º 2
0
def clear(*args, **kwargs):
  """Removes all entities from the datastore.
  """

  # there no explicit ranker model anywhere, so make one for
  # our own convenience to delete all rankers
  class ranker(db.Model):
    """ranker model used with ranklist module.
    """
    pass

  # TODO(dbentley): If there are more than 1000 instances of any model,
  # this method will not clear all instances.  Instead, it should continually
  # call .all(), delete all those, and loop until .all() is empty.
  entities = itertools.chain(*[
      Notification.all(),
      GSoCMentor.all(),
      GCIMentor.all(),
      GSoCStudent.all(),
      GCIStudent.all(),
      Survey.all(),
      SurveyContent.all(),
      SurveyRecord.all(),
      GSoCOrgAdmin.all(),
      GCIOrgAdmin.all(),
      ranker.all(),
      RankerRoot.all(),
      StudentProposal.all(),
      GSoCOrganization.all(),
      GCIOrganization.all(),
      GSoCTimeline.all(),
      GCITimeline.all(),
      GSoCProgram.all(),
      GCIProgram.all(),
      Host.all(),
      Sponsor.all(),
      User.all(),
      Site.all(),
      Document.all(),
      ])

  try:
    for entity in entities:
      entity.delete()
  except db.Timeout:
    return http.HttpResponseRedirect('#')
  # pylint: disable=E1101
  memcache.flush_all()

  return http.HttpResponse('Done')