我们从Python开源项目中,提取了以下50个代码示例,用于说明如何使用google.appengine.ext.db.Blob()。
def get_value_for_datastore(self, model_instance): flow = super(FlowProperty, self).get_value_for_datastore( model_instance) return db.Blob(pickle.dumps(flow)) # For reading from datastore.
def get_value_for_datastore(self, model_instance): logger.info("get: Got type " + str(type(model_instance))) cred = super(CredentialsProperty, self).get_value_for_datastore( model_instance) if cred is None: cred = '' else: cred = cred.to_json() return db.Blob(cred) # For reading from datastore.
def get_value_for_datastore(self, model_instance): flow = super(FlowProperty, self).get_value_for_datastore(model_instance) return db.Blob(pickle.dumps(flow)) # For reading from datastore.
def get_value_for_datastore(self, model_instance): logger.info("get: Got type " + str(type(model_instance))) cred = super(CredentialsProperty, self).get_value_for_datastore(model_instance) if cred is None: cred = '' else: cred = cred.to_json() return db.Blob(cred) # For reading from datastore.
def get_value_for_form(self, instance): """Extract the property value from the instance for use in a form. There is no way to convert a Blob into an initial value for a file upload, so we always return None. """ return None
def make_value_from_form(self, value): """Convert a form value to a property value. This extracts the content from the UploadedFile instance returned by the FileField instance. """ if have_uploadedfile and isinstance(value, uploadedfile.UploadedFile): if not self.form_value: self.form_value = value.read() b = db.Blob(self.form_value) return b return super(BlobProperty, self).make_value_from_form(value)