Skip to content

Instantly share code, notes, and snippets.

@crizCraig
Created April 10, 2012 17:56
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save crizCraig/2353256 to your computer and use it in GitHub Desktop.
Save crizCraig/2353256 to your computer and use it in GitHub Desktop.
def deletedbandmemcache():
"""Delete all entities in namespace."""
from google.appengine.api import namespace_manager
######################################
""" ####### IMPORTANT ########## """
TESTSPACE = 'test'
namespace_manager.set_namespace(TESTSPACE)
""" ##### DO NOT DELETE ######## """
######################################
dbmodelstodelete = []
for model in dbmodelstodelete:
for x in model.all():
# You could also batch these for speed.
x.delete()
memcache.flush_all()
# NDB stuff ------------------------
ndbmodelstodelete = []
for model in ndbmodelstodelete:
for x in model.query():
# There is no extra safeguard for deleting these entities :(
x.key.delete()
# Clear NDB memcache
from ndb import tasklets
tasklets.get_context().clear_cache()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment