Created
April 10, 2012 17:56
-
-
Save crizCraig/2353256 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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