Bump. Quinta-feira, 28 de Março de 2013 11:32:19 UTC, smoggy escreveu: > > Hello folks, > > So i want to generate a md5 hash of uploaded files. How can this be done ? > here is my attempt > > with the following code i get > > AttributeError: 'str' object has no attribute 'retrieve' > > So obviously the row elements are not Field type, and since i'm a python > newbie i couldn't figure this. Can anybody tip me on this ? > > > def md5_for_file(f): > ... > return md5.digest() > > db.define_table('t_products', > Field('id','id'), > Field('f_file_xplatform', type='upload'), > Field('f_file_xplatform_hash', type='string',label=T('Source File Hash')), > Field('f_file_xplatform_download_name', 'string', compute=lambda r: > download_name(r,"XPLATFORM")), > ) > > def download_name(in_row,in_os): > try: > tt_row = in_row['f_file_xplatform'].retrieve(nameonly=True) > print "tt_row: " + tt_row > t_md5 = md5_for_file(tt_row[1]) > in_row['f_file_xplatform_hash']=t_md5 > return 'blabla.'+t_md5 > > except Exception, e: > import traceback > print traceback.format_exc() > >
-- --- You received this message because you are subscribed to the Google Groups "web2py-users" group. To unsubscribe from this group and stop receiving emails from it, send an email to web2py+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out.