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


Python db.delete方法代码示例

本文整理汇总了Python中google.appengine.ext.db.delete方法的典型用法代码示例。如果您正苦于以下问题:Python db.delete方法的具体用法?Python db.delete怎么用?Python db.delete使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在google.appengine.ext.db的用法示例。


在下文中一共展示了db.delete方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: ClearDatastore

# 需要导入模块: from google.appengine.ext import db [as 别名]
# 或者: from google.appengine.ext.db import delete [as 别名]
def ClearDatastore(request):
    """Clears data in the datastore, many at a time (for admins only)."""
    clear = (None, 'None')
    atatime = 10

    msg = ''
    query = db.Query(clear[0])
    rows = query.fetch(atatime)
    length = len(rows)
    if length is 0:
        msg += 'No more rows to delete<br>'
    else:
        msg += 'Deleting %s %s<br>' % (length, clear[1])
        db.delete(rows)
        query = db.Query(clear[0])
        more = query.fetch(1)
        if len(more) is not 0:
            msg += 'Now do it again!'
            msg += '<script>window.location.href="/reflows/clear_datastore";</script>'
    return http.HttpResponse(msg) 
开发者ID:elsigh,项目名称:browserscope,代码行数:22,代码来源:util.py

示例2: post

# 需要导入模块: from google.appengine.ext import db [as 别名]
# 或者: from google.appengine.ext.db import delete [as 别名]
def post(self):
    """Handle modifying actions and redirect to a GET page."""

    if self.request.get('action:flush_memcache'):
      if memcache.flush_all():
        message = 'Cache flushed, all keys dropped.'
      else:
        message = 'Flushing the cache failed. Please try again.'
      self.redirect(self._construct_url(remove=['action:flush_memcache'],
                                        add={'message': message}))
    elif self.request.get('action:delete_entities'):
      entity_keys = self.request.params.getall('entity_key')
      db.delete(entity_keys)
      self.redirect(self._construct_url(
          remove=['action:delete_entities'],
          add={'message': '%d entities deleted' % len(entity_keys)}))
    else:
      self.error(404) 
开发者ID:elsigh,项目名称:browserscope,代码行数:20,代码来源:datastore_viewer.py

示例3: get_missing_data_users

# 需要导入模块: from google.appengine.ext import db [as 别名]
# 或者: from google.appengine.ext.db import delete [as 别名]
def get_missing_data_users():
    users = []
    for missing_user_secondary in model.MissingDataUsersSecondary.all():
      user = model.User.get_by_key_name(missing_user_secondary.email)

      # If they've added their info, delete them.
      if user.occupation and user.employer:
        db.delete(missing_user_secondary)
      else:
        # missing_user_secondary.amountCents never gets updated, but
        # that's okay, because it won't change unless the user makes a
        # new pledge, which will cause their info to be updated, so
        # we'll go down the other fork in this if.
        users.append((user, missing_user_secondary.amountCents))
    users.sort(key=lambda (_, amt): amt, reverse=True)
    return users 
开发者ID:MayOneUS,项目名称:pledgeservice,代码行数:18,代码来源:admin.py

示例4: post

# 需要导入模块: from google.appengine.ext import db [as 别名]
# 或者: from google.appengine.ext.db import delete [as 别名]
def post(self):
    """Handle modifying actions and redirect to a GET page."""
    super(DatastoreRequestHandler, self).post()
    if self.request.get('action:flush_memcache'):
      if memcache.flush_all():
        message = 'Cache flushed, all keys dropped.'
      else:
        message = 'Flushing the cache failed. Please try again.'
      self.redirect(self._construct_url(remove=['action:flush_memcache'],
                                        add={'message': message}))
    elif self.request.get('action:delete_entities'):
      entity_keys = self.request.params.getall('entity_key')
      db.delete(entity_keys)
      self.redirect(self._construct_url(
          remove=['action:delete_entities'],
          add={'message': '%d entities deleted' % len(entity_keys)}))
    else:
      self.error(404) 
开发者ID:GoogleCloudPlatform,项目名称:python-compat-runtime,代码行数:20,代码来源:datastore_viewer.py

示例5: post

# 需要导入模块: from google.appengine.ext import db [as 别名]
# 或者: from google.appengine.ext.db import delete [as 别名]
def post(self):
    """Handler for post requests to datastore_admin/backup_delete.do.

    Deletes are executed and user is redirected to the base-path handler.
    """
    backup_ids = self.request.get_all('backup_id')
    token = self.request.get('xsrf_token')
    params = ()
    if backup_ids and utils.ValidateXsrfToken(token, XSRF_ACTION):
      try:
        for backup_info in db.get(backup_ids):
          if backup_info:
            delete_backup_info(backup_info)
      except Exception, e:
        logging.exception('Failed to delete datastore backup.')
        params = [('error', e.message)] 
开发者ID:GoogleCloudPlatform,项目名称:python-compat-runtime,代码行数:18,代码来源:backup_handler.py

示例6: _cleanup_old_file

# 需要导入模块: from google.appengine.ext import db [as 别名]
# 或者: from google.appengine.ext.db import delete [as 别名]
def _cleanup_old_file(self, gcs_file):
    """Clean up the old version of a file.

    The old version may or may not be finalized yet. Either way,
    when user tries to create a file that already exists, we delete the
    old version first.

    Args:
      gcs_file: an instance of _AE_GCSFileInfo_.
    """
    if gcs_file:
      if gcs_file.finalized:
        blobkey = gcs_file.key().name()
        self.blob_storage.DeleteBlob(blobkey)
      else:
        db.delete(_AE_GCSPartialFile_.all().ancestor(gcs_file))
      gcs_file.delete() 
开发者ID:GoogleCloudPlatform,项目名称:python-compat-runtime,代码行数:19,代码来源:cloudstorage_stub.py

示例7: get_items

# 需要导入模块: from google.appengine.ext import db [as 别名]
# 或者: from google.appengine.ext.db import delete [as 别名]
def get_items(self):
        """
        Returns all the items stored in a session
        """
        items = memcache.get("_AppEngineUtilities_SessionData_" + str(self.session_key))
        if items:
            for item in items:
                if item.deleted == True:
                    item.delete()
                    items.remove(item)
            return items

        query = _AppEngineUtilities_SessionData.all()
        query.filter('session_key', self.session_key)
        results = query.fetch(1000)
        return results 
开发者ID:kuri65536,项目名称:python-for-android,代码行数:18,代码来源:sessions.py

示例8: get_item

# 需要导入模块: from google.appengine.ext import db [as 别名]
# 或者: from google.appengine.ext.db import delete [as 别名]
def get_item(self, keyname = None):
        """
        Returns a single item from the memcache or datastore
        """
        mc = memcache.get("_AppEngineUtilities_SessionData_" + str(self.session_key))
        if mc:
            for item in mc:
                if item.keyname == keyname:
                    if item.deleted == True:
                        item.delete()
                        return None
                    return item
        query = _AppEngineUtilities_SessionData.all()
        query.filter("session_key = ", self.session_key)
        query.filter("keyname = ", keyname)
        results = query.fetch(1)
        if len(results) > 0:
            memcache.set("_AppEngineUtilities_SessionData_" + str(self.session_key), self.get_items_ds())
            return results[0]
        return None 
开发者ID:kuri65536,项目名称:python-for-android,代码行数:22,代码来源:sessions.py

示例9: delete

# 需要导入模块: from google.appengine.ext import db [as 别名]
# 或者: from google.appengine.ext.db import delete [as 别名]
def delete(self):
        """
        Deletes an entity from the session in memcache and the datastore
        """
        try:
            db.delete(self)
        except:
            self.deleted = True
        mc_items = memcache.get("_AppEngineUtilities_SessionData_" + str(self.session_key))
        value_handled = False
        for item in mc_items:
            if value_handled == True:
                break
            if item.keyname == self.keyname:
                if self.deleted == True:
                    item.deleted = True
                else:
                    mc_items.remove(item)
                memcache.set("_AppEngineUtilities_SessionData_" + str(self.session_key), mc_items) 
开发者ID:kuri65536,项目名称:python-for-android,代码行数:21,代码来源:sessions.py

示例10: delete_all_sessions

# 需要导入模块: from google.appengine.ext import db [as 别名]
# 或者: from google.appengine.ext.db import delete [as 别名]
def delete_all_sessions(cls):
        """
        Deletes all sessions and session data from the data store and memcache:

        NOTE: This is not fully developed. It also will not delete any cookie
        data as this does not work for each incoming request. Keep this in mind
        if you are using the cookie writer.
        """
        all_sessions_deleted = False
        all_data_deleted = False

        while not all_sessions_deleted:
            query = _AppEngineUtilities_Session.all()
            results = query.fetch(75)
            if len(results) is 0:
                all_sessions_deleted = True
            else:
                for result in results:
                    result.delete() 
开发者ID:kuri65536,项目名称:python-for-android,代码行数:21,代码来源:sessions.py

示例11: _clean_old_sessions

# 需要导入模块: from google.appengine.ext import db [as 别名]
# 或者: from google.appengine.ext.db import delete [as 别名]
def _clean_old_sessions(self):
        """
        Delete expired sessions from the datastore.

        This is only called for CLEAN_CHECK_PERCENT percent of requests because
        it could be rather intensive.
        """
        duration = datetime.timedelta(seconds=self.session_expire_time)
        session_age = datetime.datetime.now() - duration
        query = _AppEngineUtilities_Session.all()
        query.filter('last_activity <', session_age)
        results = query.fetch(50)
        for result in results:
            """
            OLD
            data_query = _AppEngineUtilities_SessionData.all()
            data_query.filter('session', result)
            data_results = data_query.fetch(1000)
            for data_result in data_results:
                data_result.delete()
            memcache.delete('sid-'+str(result.key()))
            """
            result.delete()

    # Implement Python container methods 
开发者ID:kuri65536,项目名称:python-for-android,代码行数:27,代码来源:sessions.py

示例12: delete_item

# 需要导入模块: from google.appengine.ext import db [as 别名]
# 或者: from google.appengine.ext.db import delete [as 别名]
def delete_item(self, keyname, throw_exception=False):
        """
        Delete item from session data, ignoring exceptions if
        necessary.

        Args:
            keyname: The keyname of the object to delete.
            throw_exception: false if exceptions are to be ignored.
        Returns:
            Nothing.
        """
        if throw_exception:
            self.__delitem__(keyname)
            return None
        else:
            try:
                self.__delitem__(keyname)
            except KeyError:
                return None 
开发者ID:kuri65536,项目名称:python-for-android,代码行数:21,代码来源:sessions.py

示例13: delete_album

# 需要导入模块: from google.appengine.ext import db [as 别名]
# 或者: from google.appengine.ext.db import delete [as 别名]
def delete_album(self, request):
    """Delete album from library."""
    def do_deletion():
      album = model.AlbumInfo.get(request.album_id)

      artist = album.artist
      artist.album_count -= 1
      artist.put()

      if album:
        db.delete(model.Info.all(keys_only=True).ancestor(album))
        return True
      else:
        return False

    return DeleteAlbumResponse(album_deleted=db.run_in_transaction(do_deletion)) 
开发者ID:google,项目名称:protorpc,代码行数:18,代码来源:tunes_db.py

示例14: run

# 需要导入模块: from google.appengine.ext import db [as 别名]
# 或者: from google.appengine.ext.db import delete [as 别名]
def run(self, job_ids):
    result = []
    for job_id in job_ids:
      db.delete(_OutputFile.all().ancestor(_OutputFile.get_root_key(job_id))) 
开发者ID:elsigh,项目名称:browserscope,代码行数:6,代码来源:shuffler.py

示例15: handle

# 需要导入模块: from google.appengine.ext import db [as 别名]
# 或者: from google.appengine.ext.db import delete [as 别名]
def handle(self):
    mapreduce_id = self.request.get("mapreduce_id")
    mapreduce_state = model.MapreduceState.get_by_job_id(mapreduce_id)
    if mapreduce_state:
      config=util.create_datastore_write_config(mapreduce_state.mapreduce_spec)
      db.delete(model.MapreduceControl.get_key_by_job_id(mapreduce_id),
              config=config)
      shard_states = model.ShardState.find_by_mapreduce_state(mapreduce_state)
      for shard_state in shard_states:
        db.delete(model._HugeTaskPayload.all().ancestor(shard_state),
                  config=config)
      db.delete(model._HugeTaskPayload.all().ancestor(mapreduce_state),
                config=config) 
开发者ID:elsigh,项目名称:browserscope,代码行数:15,代码来源:handlers.py


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