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