def is_valid(self, form): obj = form.save() image_zip = self.request.get('image_zip') try: myzip = zipfile.ZipFile(StringIO.StringIO(image_zip), 'r') for name in myzip.namelist(): image = myzip.read(name) picture = Picture(gallery=obj, image=db.Blob(watermark(image))) picture.put() except zipfile.BadZipfile: pass self.redirect(self.get_redirect(obj))
def testPicturePrice(self): gallery = Gallery(title='g1') gallery.put() test_price = 1.99 # price is actualy save in _price_by_cent as int # befor saving it convert to 199, then when retrieve it convert back picture = Picture( gallery=gallery, title='p1', price=test_price ) picture.put() # test price is still orignal value self.assertEqual(picture.price, test_price)