I would take "compute=lambda r: THUMB(r)" out of the table definition and add
db.table.logo_small.compute=THUMB in the controller action where you have insert/update forms. On Dec 19, 5:34 am, Kuba Kucharski <[email protected]> wrote: > Looks like I have a problem. I want to compute field like this and it > works FINE: > > Field('logo_small','upload',writable=False,readable=False,widget=uploadWidget,compute=lambda > r: THUMB(r)), > > def THUMB(r): > > try: > image=r['logo'] > except: > #yes, None is deleting my thumbnail > return None > > from PIL import Image > import os > im = Image.open(request.folder + 'uploads/' + image) > maxheight=50 > maxwidth=100 > xsize, ysize = im.size > ratio=min(maxwidth/float(xsize), maxheight/float(ysize)) > newxsize=int(xsize*ratio) > newysize=int(ysize*ratio) > im=im.resize((newxsize, newysize), Image.ANTIALIAS) > root,ext = os.path.splitext(image) > thumb='%s_thumb%s' %(root, ext) > im.save(request.folder + 'uploads/' + thumb) > return thumb > > But there is a problem with this behaviour. When I do somewhere else > db(db.product.id==id).update(somefield="",someother="") > AND LIST OF FIELDS UPDATED DOES NOT CONTAIN LOGO FIELD > it is throwing exception - understandable > what should I write in my code in the exception > or should we change that? > like somehow disable compute in the update statement > > -- > Kuba

