本文整理汇总了Python中google.appengine.ext.ndb.delete_multi方法的典型用法代码示例。如果您正苦于以下问题:Python ndb.delete_multi方法的具体用法?Python ndb.delete_multi怎么用?Python ndb.delete_multi使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类google.appengine.ext.ndb
的用法示例。
在下文中一共展示了ndb.delete_multi方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: repo_cleanup
# 需要导入模块: from google.appengine.ext import ndb [as 别名]
# 或者: from google.appengine.ext.ndb import delete_multi [as 别名]
def repo_cleanup(days, cursor=None):
before_date = datetime.utcnow() - timedelta(days=days)
repo_qry = model.Repo.query().filter(model.Repo.modified < before_date)
repo_keys, repo_cursors = util.get_dbs(
repo_qry,
order='modified',
keys_only=True,
cursor=cursor,
)
ndb.delete_multi(repo_keys)
if repo_cursors['next']:
deferred.defer(repo_cleanup, days, repo_cursors['next'])
###############################################################################
# Account Clean-ups
###############################################################################
示例2: account_cleanup
# 需要导入模块: from google.appengine.ext import ndb [as 别名]
# 或者: from google.appengine.ext.ndb import delete_multi [as 别名]
def account_cleanup(stars, cursor=None):
account_qry = model.Account.query().filter(model.Account.stars < stars)
account_keys, account_cursors = util.get_dbs(
account_qry,
order='stars',
keys_only=True,
cursor=cursor,
)
ndb.delete_multi(account_keys)
if account_cursors['next']:
deferred.defer(account_cleanup, days, account_cursors['next'])
###############################################################################
# Rank Accounts
###############################################################################
示例3: task_delete_tasks
# 需要导入模块: from google.appengine.ext import ndb [as 别名]
# 或者: from google.appengine.ext.ndb import delete_multi [as 别名]
def task_delete_tasks(task_ids):
"""Deletes the specified tasks, a list of string encoded task ids."""
total = 0
count = 0
opt = ndb.QueryOptions(use_cache=False, use_memcache=False, keys_only=True)
try:
for task_id in task_ids:
request_key = task_pack.unpack_request_key(task_id)
# Delete the whole group. An ancestor query will retrieve the entity
# itself too, so no need to explicitly delete it.
keys = ndb.Query(default_options=opt, ancestor=request_key).fetch()
if not keys:
# Can happen if it is a retry.
continue
ndb.delete_multi(keys)
total += len(keys)
count += 1
return count
finally:
logging.info(
'Deleted %d TaskRequest groups; %d entities in total', count, total)
示例4: PutResource
# 需要导入模块: from google.appengine.ext import ndb [as 别名]
# 或者: from google.appengine.ext.ndb import delete_multi [as 别名]
def PutResource(url, etag, content):
"""Persist a resource."""
key = ndb.Key(Resource, url, namespace=settings.PLAYGROUND_NAMESPACE)
keys = ndb.Query(ancestor=key).fetch(keys_only=True)
ndb.delete_multi(keys)
resource = Resource(id=url, etag=etag,
namespace=settings.PLAYGROUND_NAMESPACE)
if len(content) <= _MAX_RAW_PROPERTY_BYTES:
resource.content = content
resource.put()
return
chunks = [content[i:i + _MAX_RAW_PROPERTY_BYTES]
for i in range(0, len(content), _MAX_RAW_PROPERTY_BYTES)]
entities = [ResourceChunk(id=i + 1, parent=resource.key, content=chunks[i])
for i in range(0, len(chunks))]
entities.append(resource)
ndb.put_multi(entities)
示例5: DeleteReposAndTemplateProjects
# 需要导入模块: from google.appengine.ext import ndb [as 别名]
# 或者: from google.appengine.ext.ndb import delete_multi [as 别名]
def DeleteReposAndTemplateProjects():
"""Delete repos and related template projects."""
user = GetPublicTemplateOwner()
# delete template projects
keys = user.projects
ndb.delete_multi(keys)
# delete ANONYMOUS user
user.key.delete()
# delete code repositories
query = Repo.query(namespace=settings.PLAYGROUND_NAMESPACE)
keys = query.fetch(keys_only=True)
ndb.delete_multi(keys)
# delete repo collections
query = RepoCollection.query(ancestor=GetGlobalRootEntity().key)
keys = query.fetch(keys_only=True)
ndb.delete_multi(keys)
# flush memcache
memcache.flush_all()
示例6: testGetVotes_Inactive
# 需要导入模块: from google.appengine.ext import ndb [as 别名]
# 或者: from google.appengine.ext.ndb import delete_multi [as 别名]
def testGetVotes_Inactive(self):
self.assertLen(self.blockable_1.GetVotes(), 0)
test_utils.CreateVotes(self.blockable_1, 2)
self.assertLen(self.blockable_1.GetVotes(), 2)
votes = vote_models.Vote.query().fetch()
new_votes = []
for vote in votes:
new_key = ndb.Key(flat=vote.key.flat()[:-1] + (None,))
new_votes.append(datastore_utils.CopyEntity(vote, new_key=new_key))
ndb.delete_multi(vote.key for vote in votes)
ndb.put_multi(new_votes)
self.assertLen(self.blockable_1.GetVotes(), 0)
示例7: test_list_tags_none
# 需要导入模块: from google.appengine.ext import ndb [as 别名]
# 或者: from google.appengine.ext.ndb import delete_multi [as 别名]
def test_list_tags_none(self):
ndb.delete_multi(tag_model.Tag.query().fetch(keys_only=True))
(query_results, cursor,
has_additional_results), total_pages = tag_model.Tag.list()
self.assertEmpty(query_results)
self.assertIsNone(cursor)
self.assertFalse(has_additional_results)
self.assertEqual(total_pages, 0)
示例8: __flush_ndb_deletes
# 需要导入模块: from google.appengine.ext import ndb [as 别名]
# 或者: from google.appengine.ext.ndb import delete_multi [as 别名]
def __flush_ndb_deletes(self):
"""Flush all deletes to datastore."""
if self.ndb_deletes.length:
ndb.delete_multi(self.ndb_deletes.items, config=self.__create_config())
self.ndb_deletes.clear()
示例9: delete_user_dbs
# 需要导入模块: from google.appengine.ext import ndb [as 别名]
# 或者: from google.appengine.ext.ndb import delete_multi [as 别名]
def delete_user_dbs(user_db_keys):
ndb.delete_multi(user_db_keys)
示例10: get
# 需要导入模块: from google.appengine.ext import ndb [as 别名]
# 或者: from google.appengine.ext.ndb import delete_multi [as 别名]
def get(self):
deleteBeforeDate = datetime.datetime.now() - datetime.timedelta(minutes = self.keepForMinutes)
ndb.delete_multi(Task.gql('WHERE date < :1', deleteBeforeDate).fetch(keys_only = True))
示例11: _flush_ndb_deletes
# 需要导入模块: from google.appengine.ext import ndb [as 别名]
# 或者: from google.appengine.ext.ndb import delete_multi [as 别名]
def _flush_ndb_deletes(self, items, options):
"""Flush all deletes to datastore."""
assert ndb is not None
ndb.delete_multi(items, config=self._create_config(options))
示例12: FlushAllCaches
# 需要导入模块: from google.appengine.ext import ndb [as 别名]
# 或者: from google.appengine.ext.ndb import delete_multi [as 别名]
def FlushAllCaches():
"""Removes any cached data from datastore/memache."""
chart_data_keys = ChartData.query().fetch(keys_only=True)
ndb.delete_multi(chart_data_keys)
project_list_keys = Projects.query().fetch(keys_only=True)
ndb.delete_multi(project_list_keys)
示例13: delete_old_news
# 需要导入模块: from google.appengine.ext import ndb [as 别名]
# 或者: from google.appengine.ext.ndb import delete_multi [as 别名]
def delete_old_news():
q = NewsEntry.query(NewsEntry.important == True).order(-NewsEntry.published)
ndb.delete_multi(q.fetch(offset=app.config["PER_PAGE"], keys_only=True))
q = NewsEntry.query(NewsEntry.important == False).order(-NewsEntry.published)
ndb.delete_multi(q.fetch(offset=app.config["PER_PAGE"], keys_only=True))
return "Done", 200
示例14: delete_entries
# 需要导入模块: from google.appengine.ext import ndb [as 别名]
# 或者: from google.appengine.ext.ndb import delete_multi [as 别名]
def delete_entries():
return ndb.delete_multi(CronLog.query().fetch(keys_only=True))
# Parameters
# site: site url string
# Returns
# gsc-style date or never string
示例15: operate_on_multiple_keys_at_once
# 需要导入模块: from google.appengine.ext import ndb [as 别名]
# 或者: from google.appengine.ext.ndb import delete_multi [as 别名]
def operate_on_multiple_keys_at_once(list_of_entities):
list_of_keys = ndb.put_multi(list_of_entities)
list_of_entities = ndb.get_multi(list_of_keys)
ndb.delete_multi(list_of_keys)