def validate(self, value): """Makes sure that whatever you are putting, does not exceed size""" value = super(Blob,self).validate(value) if self.size <= -1: return value inBytes = Size.inBytes(value) if not inBytes <= self.size : raise BadValueError("Your blob size must be less than: %s , got: %s" % self.size, inBytes ) if not isinstance(value, blob): if isinstance(value, basestring): value = blob(value) else: value = blob(str(value)) return value
def deconvert(self, value): '''Change a JSON repr of a blob stored in the datastore to a python object''' new = blob() loaded = yaml.load(value) for name, value in loaded.items(): setattr(new, name, value) return new
def testBlobAcceptsBlobs(self): '''Verifies that you can use the `blob` builtin with the Blob descriptor''' image = blob("Some stupid content" * 50, mimetype="application/text") self.test.image = image