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


Python blobstore.delete方法代码示例

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


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

示例1: test_post

# 需要导入模块: from google.appengine.ext import blobstore [as 别名]
# 或者: from google.appengine.ext.blobstore import delete [as 别名]
def test_post(self):
    request = webapp2.Request.blank(
        '/blobstore',
        method='POST',
        POST=multidict.MultiDict([('blob_key', 'a'),
                                  ('blob_key', 'b')]))
    response = webapp2.Response()
    handler = blobstore_viewer.BlobstoreRequestHandler(request, response)

    self.mox.StubOutWithMock(blobstore, 'delete')
    blobstore.delete(['a', 'b'])

    self.mox.ReplayAll()
    handler.post()
    self.mox.VerifyAll()
    self.assertEqual(302, response.status_int)
    self.assertEqual('http://localhost/blobstore',
                     response.headers.get('Location')) 
开发者ID:elsigh,项目名称:browserscope,代码行数:20,代码来源:blobstore_viewer_test.py

示例2: test_post

# 需要导入模块: from google.appengine.ext import blobstore [as 别名]
# 或者: from google.appengine.ext.blobstore import delete [as 别名]
def test_post(self):
    request = webapp2.Request.blank(
        '/blobstore',
        method='POST',
        POST=multidict.MultiDict([('blob_key', 'a'),
                                  ('blob_key', 'b')]))
    response = webapp2.Response()
    handler = blobstore_viewer.BlobstoreRequestHandler(request, response)
    admin_request_handler.AdminRequestHandler(handler).post()
    self.mox.StubOutWithMock(blobstore, 'delete')
    blobstore.delete(['a', 'b'])

    self.mox.ReplayAll()
    handler.post()
    self.mox.VerifyAll()
    self.assertEqual(302, response.status_int)
    self.assertEqual('http://localhost/blobstore',
                     response.headers.get('Location')) 
开发者ID:GoogleCloudPlatform,项目名称:python-compat-runtime,代码行数:20,代码来源:blobstore_viewer_test.py

示例3: post

# 需要导入模块: from google.appengine.ext import blobstore [as 别名]
# 或者: from google.appengine.ext.blobstore import delete [as 别名]
def post(self):
    """Deletes blobs identified in 'blob_key' form variables.

    Multiple keys can be specified e.g. '...&blob_key=key1&blob_key=key2'.

    Redirects the client back to the value specified in the 'return_to' form
    variable.
    """
    redirect_url = str(self.request.get('return_to', '/blobstore'))
    keys = self.request.get_all('blob_key')
    blobstore.delete(keys)
    self.redirect(redirect_url) 
开发者ID:elsigh,项目名称:browserscope,代码行数:14,代码来源:blobstore_viewer.py

示例4: cleanup

# 需要导入模块: from google.appengine.ext import blobstore [as 别名]
# 或者: from google.appengine.ext.blobstore import delete [as 别名]
def cleanup(blob_keys):
    blobstore.delete(blob_keys) 
开发者ID:raonyguimaraes,项目名称:mendelmd,代码行数:4,代码来源:main.py

示例5: post

# 需要导入模块: from google.appengine.ext import blobstore [as 别名]
# 或者: from google.appengine.ext.blobstore import delete [as 别名]
def post(self):
        if (self.request.get('_method') == 'DELETE'):
            return self.delete()
        result = {'files': self.handle_upload()}
        s = json.dumps(result, separators=(',', ':'))
        redirect = self.request.get('redirect')
        if redirect:
            return self.redirect(str(
                redirect.replace('%s', urllib.quote(s, ''), 1)
            ))
        if 'application/json' in self.request.headers.get('Accept'):
            self.response.headers['Content-Type'] = 'application/json'
        self.response.write(s) 
开发者ID:raonyguimaraes,项目名称:mendelmd,代码行数:15,代码来源:main.py

示例6: delete

# 需要导入模块: from google.appengine.ext import blobstore [as 别名]
# 或者: from google.appengine.ext.blobstore import delete [as 别名]
def delete(self):
        key = self.request.get('key') or ''
        blobstore.delete(key)
        s = json.dumps({key: True}, separators=(',', ':'))
        if 'application/json' in self.request.headers.get('Accept'):
            self.response.headers['Content-Type'] = 'application/json'
        self.response.write(s) 
开发者ID:raonyguimaraes,项目名称:mendelmd,代码行数:9,代码来源:main.py

示例7: get

# 需要导入模块: from google.appengine.ext import blobstore [as 别名]
# 或者: from google.appengine.ext.blobstore import delete [as 别名]
def get(self):
        # Get the default Cloud Storage Bucket name and create a file name for
        # the object in Cloud Storage.
        bucket = app_identity.get_default_gcs_bucket_name()

        # Cloud Storage file names are in the format /bucket/object.
        filename = '/{}/blobstore_demo'.format(bucket)

        # Create a file in Google Cloud Storage and write something to it.
        with cloudstorage.open(filename, 'w') as filehandle:
            filehandle.write('abcde\n')

        # In order to read the contents of the file using the Blobstore API,
        # you must create a blob_key from the Cloud Storage file name.
        # Blobstore expects the filename to be in the format of:
        # /gs/bucket/object
        blobstore_filename = '/gs{}'.format(filename)
        blob_key = blobstore.create_gs_key(blobstore_filename)

        # Read the file's contents using the Blobstore API.
        # The last two parameters specify the start and end index of bytes we
        # want to read.
        data = blobstore.fetch_data(blob_key, 0, 6)

        # Write the contents to the response.
        self.response.headers['Content-Type'] = 'text/plain'
        self.response.write(data)

        # Delete the file from Google Cloud Storage using the blob_key.
        blobstore.delete(blob_key)


# This handler creates a file in Cloud Storage using the cloudstorage
# client library and then serves the file back using the Blobstore API. 
开发者ID:GoogleCloudPlatform,项目名称:python-docs-samples,代码行数:36,代码来源:main.py

示例8: post

# 需要导入模块: from google.appengine.ext import blobstore [as 别名]
# 或者: from google.appengine.ext.blobstore import delete [as 别名]
def post(self):
    """Deletes blobs identified in 'blob_key' form variables.

    Multiple keys can be specified e.g. '...&blob_key=key1&blob_key=key2'.

    Redirects the client back to the value specified in the 'return_to' form
    variable.
    """
    super(BlobstoreRequestHandler, self).post()
    redirect_url = str(self.request.get('return_to', '/blobstore'))
    keys = self.request.get_all('blob_key')
    blobstore.delete(keys)
    self.redirect(redirect_url) 
开发者ID:GoogleCloudPlatform,项目名称:python-compat-runtime,代码行数:15,代码来源:blobstore_viewer.py

示例9: get

# 需要导入模块: from google.appengine.ext import blobstore [as 别名]
# 或者: from google.appengine.ext.blobstore import delete [as 别名]
def get(self):
        # Get the default Cloud Storage Bucket name and create a file name for
        # the object in Cloud Storage.
        bucket = app_identity.get_default_gcs_bucket_name()

        # Cloud Storage file names are in the format /bucket/object.
        filename = '/{}/blobreader_demo'.format(bucket)

        # Create a file in Google Cloud Storage and write something to it.
        with cloudstorage.open(filename, 'w') as filehandle:
            filehandle.write('abcde\n')

        # In order to read the contents of the file using the Blobstore API,
        # you must create a blob_key from the Cloud Storage file name.
        # Blobstore expects the filename to be in the format of:
        # /gs/bucket/object
        blobstore_filename = '/gs{}'.format(filename)
        blob_key = blobstore.create_gs_key(blobstore_filename)

        # [START gae_blobstore_reader]
        # Instantiate a BlobReader for a given Blobstore blob_key.
        blob_reader = blobstore.BlobReader(blob_key)

        # Instantiate a BlobReader for a given Blobstore blob_key, setting the
        # buffer size to 1 MB.
        blob_reader = blobstore.BlobReader(blob_key, buffer_size=1048576)

        # Instantiate a BlobReader for a given Blobstore blob_key, setting the
        # initial read position.
        blob_reader = blobstore.BlobReader(blob_key, position=0)

        # Read the entire value into memory. This may take a while depending
        # on the size of the value and the size of the read buffer, and is not
        # recommended for large values.
        blob_reader_data = blob_reader.read()

        # Write the contents to the response.
        self.response.headers['Content-Type'] = 'text/plain'
        self.response.write(blob_reader_data)

        # Set the read position back to 0, then read and write 3 bytes.
        blob_reader.seek(0)
        blob_reader_data = blob_reader.read(3)
        self.response.write(blob_reader_data)
        self.response.write('\n')

        # Set the read position back to 0, then read and write one line (up to
        # and including a '\n' character) at a time.
        blob_reader.seek(0)
        for line in blob_reader:
            self.response.write(line)
        # [END gae_blobstore_reader]

        # Delete the file from Google Cloud Storage using the blob_key.
        blobstore.delete(blob_key) 
开发者ID:GoogleCloudPlatform,项目名称:python-docs-samples,代码行数:57,代码来源:main.py

示例10: delete

# 需要导入模块: from google.appengine.ext import blobstore [as 别名]
# 或者: from google.appengine.ext.blobstore import delete [as 别名]
def delete(*filenames):
  """Permanently delete files.

  Delete on non-finalized/non-existent files is a no-op.

  Args:
    filenames: finalized file names as strings. filename should has format
      "/gs/bucket/filename" or "/blobstore/blobkey".

  Raises:
    InvalidFileNameError: Raised when any filename is not of valid format or
      not a finalized name.
    IOError: Raised if any problem occurs contacting the backend system.
  """

  from google.appengine.api.files import blobstore as files_blobstore
  from google.appengine.api.files import gs
  from google.appengine.ext import blobstore

  blobkeys = []

  for filename in filenames:
    if not isinstance(filename, basestring):
      raise InvalidArgumentError('Filename should be a string, but is %s(%r)' %
                                 (filename.__class__.__name__, filename))
    if filename.startswith(files_blobstore._BLOBSTORE_DIRECTORY):
      __checkIsFinalizedName(filename)
      blobkey = files_blobstore.get_blob_key(filename)
      if blobkey:
        blobkeys.append(blobkey)
    elif filename.startswith(gs._GS_PREFIX):

      __checkIsFinalizedName(filename)
      blobkeys.append(blobstore.create_gs_key(filename))
    else:
      raise InvalidFileNameError('Filename should start with /%s or /%s' %
                                 (files_blobstore._BLOBSTORE_DIRECTORY,
                                 gs._GS_PREFIX))

  try:
    blobstore.delete(blobkeys)
  except Exception, e:
    raise IOError('Blobstore failure.', e) 
开发者ID:GoogleCloudPlatform,项目名称:python-compat-runtime,代码行数:45,代码来源:file.py


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