App Engine Python SDK  v1.6.9 rev.445
The Python runtime is available as an experimental Preview feature.
Classes | Functions | Variables
google.appengine.ext.ndb.blobstore Namespace Reference

Classes

class  BlobInfo
 
class  BlobReader
 

Functions

def delete
 
def delete_async
 
def delete_multi
 
def delete_multi_async
 
def create_upload_url
 
def create_upload_url_async
 
def parse_blob_info
 
def fetch_data
 
def fetch_data_async
 

Variables

list __all__
 
 Error = blobstore.Error
 
 InternalError = blobstore.InternalError
 
 BlobFetchSizeTooLargeError = blobstore.BlobFetchSizeTooLargeError
 
 BlobNotFoundError = blobstore.BlobNotFoundError
 
 _CreationFormatError = blobstore._CreationFormatError
 
 DataIndexOutOfRangeError = blobstore.DataIndexOutOfRangeError
 
 PermissionDeniedError = blobstore.PermissionDeniedError
 
 BlobInfoParseError = ext_blobstore.BlobInfoParseError
 
 BlobKey = blobstore.BlobKey
 
 BLOB_INFO_KIND = blobstore.BLOB_INFO_KIND
 
 BLOB_MIGRATION_KIND = blobstore.BLOB_MIGRATION_KIND
 
 BLOB_KEY_HEADER = blobstore.BLOB_KEY_HEADER
 
 BLOB_RANGE_HEADER = blobstore.BLOB_RANGE_HEADER
 
 MAX_BLOB_FETCH_SIZE = blobstore.MAX_BLOB_FETCH_SIZE
 
 UPLOAD_INFO_CREATION_HEADER = blobstore.UPLOAD_INFO_CREATION_HEADER
 
 BlobKeyProperty = model.BlobKeyProperty
 
 get = BlobInfo.get
 
 get_async = BlobInfo.get_async
 
 get_multi = BlobInfo.get_multi
 
 get_multi_async = BlobInfo.get_multi_async
 

Detailed Description

NDB interface for Blobstore.

This currently builds on google.appengine.ext.blobstore and provides a
similar API.  The main API differences:

- BlobInfo is an actual Model subclass rather than a pseudo-model class.
  To query, use BlobInfo.query() and its documented properties.  Other
  changes:
  - The kind is '__BlobInfo__' (BLOB_INFO_KIND).
  - key() is a method returning a BlobKey instance.
  - put() and friends are disabled.
  - Added class methods get() and friends.
  - Added instance methods delete() and friends, and open().

- Instead of BlobReferenceProperty, there's BlobKeyProperty.

- There is no create_rpc() function.  Instead, functions and methods
  take keyword arguments to specify deadline, callback, and (in some
  case) datastore options.

- APIs (get() and delete()) that in ext.blobstore take either a blob
  key or a list of blob keys are split into two: one that takes a blob
  key and one that takes a list of blob keys, the latter having a name
  ending in _multi.

- The following APIs have a synchronous and an async version:
  - BlobInfo.get()
  - BlobInfo.delete()
  - create_upload_url()
  - get()
  - get_multi()
  - delete()
  - delete_multi()
  - fetch_data()

Function Documentation

def google.appengine.ext.ndb.blobstore.create_upload_url (   success_path,
  max_bytes_per_blob = None,
  max_bytes_total = None,
  options 
)
Create upload URL for POST form.

Args:
  success_path: Path within application to call when POST is successful
    and upload is complete.
  max_bytes_per_blob: The maximum size in bytes that any one blob in the
    upload can be or None for no maximum size.
  max_bytes_total: The maximum size in bytes that the aggregate sizes of all
    of the blobs in the upload can be or None for no maximum size.
  **options: Options for create_rpc().

Returns:
  The upload URL.

Raises:
  TypeError: If max_bytes_per_blob or max_bytes_total are not integral types.
  ValueError: If max_bytes_per_blob or max_bytes_total are not
    positive values.
def google.appengine.ext.ndb.blobstore.create_upload_url_async (   success_path,
  max_bytes_per_blob = None,
  max_bytes_total = None,
  options 
)
Async version of create_upload_url().
def google.appengine.ext.ndb.blobstore.delete (   blob_key,
  options 
)
Delete a blob from Blobstore.

Args:
  blob_key: A blob key.  This may be a str, unicode or BlobKey instance.
  **options: Options for create_rpc().
def google.appengine.ext.ndb.blobstore.delete_async (   blob_key,
  options 
)
Async version of delete().
def google.appengine.ext.ndb.blobstore.delete_multi (   blob_keys,
  options 
)
Delete blobs from Blobstore.

Args:
  blob_keys: A list of blob keys.
  **options: Options for create_rpc().
def google.appengine.ext.ndb.blobstore.delete_multi_async (   blob_keys,
  options 
)
Async version of delete_multi().
def google.appengine.ext.ndb.blobstore.fetch_data (   blob,
  start_index,
  end_index,
  options 
)
Fetch data for blob.

Fetches a fragment of a blob up to MAX_BLOB_FETCH_SIZE in length.  Attempting
to fetch a fragment that extends beyond the boundaries of the blob will return
the amount of data from start_index until the end of the blob, which will be
a smaller size than requested.  Requesting a fragment which is entirely
outside the boundaries of the blob will return empty string.  Attempting
to fetch a negative index will raise an exception.

Args:
  blob: BlobInfo, BlobKey, str or unicode representation of BlobKey of
    blob to fetch data from.
  start_index: Start index of blob data to fetch.  May not be negative.
  end_index: End index (inclusive) of blob data to fetch.  Must be
    >= start_index.
  **options: Options for create_rpc().

Returns:
  str containing partial data of blob.  If the indexes are legal but outside
  the boundaries of the blob, will return empty string.

Raises:
  TypeError if start_index or end_index are not indexes.  Also when blob
    is not a string, BlobKey or BlobInfo.
  DataIndexOutOfRangeError when start_index < 0 or end_index < start_index.
  BlobFetchSizeTooLargeError when request blob fragment is larger than
    MAX_BLOB_FETCH_SIZE.
  BlobNotFoundError when blob does not exist.
def google.appengine.ext.ndb.blobstore.fetch_data_async (   blob,
  start_index,
  end_index,
  options 
)
Async version of fetch_data().
def google.appengine.ext.ndb.blobstore.parse_blob_info (   field_storage)
Parse a BlobInfo record from file upload field_storage.

Args:
  field_storage: cgi.FieldStorage that represents uploaded blob.

Returns:
  BlobInfo record as parsed from the field-storage instance.
  None if there was no field_storage.

Raises:
  BlobInfoParseError when provided field_storage does not contain enough
  information to construct a BlobInfo object.

Variable Documentation

list google.appengine.ext.ndb.blobstore.__all__
Initial value:
1 = ['BLOB_INFO_KIND',
2  'BLOB_KEY_HEADER',
3  'BLOB_MIGRATION_KIND',
4  'BLOB_RANGE_HEADER',
5  'BlobFetchSizeTooLargeError',
6  'BlobInfo',
7  'BlobInfoParseError',
8  'BlobKey',
9  'BlobNotFoundError',
10  'BlobKeyProperty',
11  'BlobReader',
12  'DataIndexOutOfRangeError',
13  'PermissionDeniedError',
14  'Error',
15  'InternalError',
16  'MAX_BLOB_FETCH_SIZE',
17  'UPLOAD_INFO_CREATION_HEADER',
18  'create_upload_url',
19  'create_upload_url_async',
20  'delete',
21  'delete_async',
22  'delete_multi',
23  'delete_multi_async',
24  'fetch_data',
25  'fetch_data_async',
26  'get',
27  'get_async',
28  'get_multi',
29  'get_multi_async',
30  'parse_blob_info']