當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。