当前位置: 首页>>代码示例>>Python>>正文


Python ndb.delete_multi方法代码示例

本文整理汇总了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
############################################################################### 
开发者ID:lipis,项目名称:github-stats,代码行数:20,代码来源:task.py

示例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
############################################################################### 
开发者ID:lipis,项目名称:github-stats,代码行数:19,代码来源:task.py

示例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) 
开发者ID:luci,项目名称:luci-py,代码行数:23,代码来源:task_request.py

示例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) 
开发者ID:googlearchive,项目名称:cloud-playground,代码行数:19,代码来源:model.py

示例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() 
开发者ID:googlearchive,项目名称:cloud-playground,代码行数:25,代码来源:model.py

示例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) 
开发者ID:google,项目名称:upvote,代码行数:18,代码来源:binary_test.py

示例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) 
开发者ID:google,项目名称:loaner,代码行数:10,代码来源:tag_model_test.py

示例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() 
开发者ID:elsigh,项目名称:browserscope,代码行数:7,代码来源:context.py

示例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) 
开发者ID:lipis,项目名称:github-stats,代码行数:4,代码来源:user.py

示例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)) 
开发者ID:ma1co,项目名称:Sony-PMCA-RE,代码行数:5,代码来源:main.py

示例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)) 
开发者ID:singhj,项目名称:locality-sensitive-hashing,代码行数:6,代码来源:context.py

示例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) 
开发者ID:googlearchive,项目名称:billing-export-python,代码行数:8,代码来源:main.py

示例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 
开发者ID:liantian-cn,项目名称:RSSNewsGAE,代码行数:8,代码来源:background.py

示例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 
开发者ID:jroakes,项目名称:gsc-logger,代码行数:10,代码来源:utils_db.py

示例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) 
开发者ID:GoogleCloudPlatform,项目名称:python-docs-samples,代码行数:6,代码来源:snippets.py


注:本文中的google.appengine.ext.ndb.delete_multi方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。