What does "writable=false if forms" mean and WHAT should I apply this to?
And where should I plug this "URL('mydownload', ... ) into? Sorry, but I understand if you just write some web2py-specific code completely out of contex. It requires some explanation. W dniu niedziela, 3 sierpnia 2014 00:22:57 UTC+2 użytkownik Massimo Di Pierro napisał: > > Than it is easy. make it writable=false if forms. > Store your filename in the the upload field. But instead of > > URL('download',....) > > use > > URL('mydownload',....) > > > Where: > > def mydownload(): > fullname = os.path.join(os.path.join, 'private', request.args(0)) > response.stream(fullname) > > > On Wednesday, 30 July 2014 03:00:48 UTC-5, Kuba Kozłowicz wrote: >> >> f_invoice_file_path is location where the file is stored by myself, >> because I generate these files myself and I save them myself as well. It >> contains whole path to the file ( with the filename and its extension ). >> They are stored under "private" directory with the structure I described >> above. I don't need web2py to handle writing of these files ( because I am >> doing it myself ), I just need to be able to browse and download these file >> in SMART GRID as well as on VIEW page. And since I don't use default web2py >> storing mechanism ( which does some name changing ) I can't simply do that >> or I don't know how to do it. >> >> W dniu wtorek, 29 lipca 2014 17:35:02 UTC+2 użytkownik Massimo Di Pierro >> napisał: >>> >>> Let me understand this better f_invoice_file_path is the location where >>> the file is supposed to be stored or is it the full path including the >>> desired filename? Do you handle the file writing or should web2py do it >>> automatically? >>> >>> >>> On Tuesday, 29 July 2014 05:59:10 UTC-5, Kuba Kozłowicz wrote: >>>> >>>> I have three tables: >>>> >>>> - invoices >>>> - invoice summaries >>>> - invoice bundles >>>> >>>> The website I am working on provides such a functionality, that user >>>> uploads a file, from which invoices and invoice summaries are generated >>>> and >>>> after being generated they are zipped and put into a bundle. >>>> >>>> For each upload I create following structure for storing these files: >>>> >>>> invoices/ >>>> /<bundle_id>/<list of invoices of bundle <bundle_id>>/ >>>> summaries/ >>>> /<bundle_id>/<list of invoices of bundle <bundle_id>>/ >>>> bundles/ >>>> /<bundle_id>/<list of invoices of bundle <bundle_id>>/ >>>> >>>> >>>> >>>> So I end up having something that looks like this >>>> >>>> invoices/ >>>> /1/<list of invoices of bundle_1>/ >>>> /invoice1.pdf >>>> /invoice2.pdf >>>> /2/<list of invoices of bundle_2>/ >>>> /invoice1.pdf >>>> /invoice2.pdf >>>> /3/<list of invoices of bundle_3>/ >>>> /invoice1.pdf >>>> /invoice2.pdf >>>> summaries/ >>>> /1/<list of summaries of bundle_1>/ >>>> /summary1.pdf >>>> /2/<list of summaries of bundle_2>/ >>>> /summary1.pdf >>>> /3/<list of summaries of bundle_3>/ >>>> /summary1.pdf >>>> bundles/ >>>> /1/<bundle_1>/ >>>> /bundle.zip >>>> /2/<bundle_2>/ >>>> /bundle.zip >>>> /3/<bundle_3>/ >>>> /bundle.zip >>>> >>>> >>>> >>>> >>>> where inner folder name is ID of recently created bundle. >>>> >>>> Now to provide CRUD functionality I am using SMART GRID and I want to >>>> be able to display the file of invoice, summary, bundle entries ( by >>>> displaying I mean I want to display file's name and allow downloading it >>>> ), >>>> when a user either chooses VIEW in the SMART GRID or when he looks at the >>>> list of entries. Since I've chosen my own folder structure for storing >>>> these invoices, summaries and bundles I can't do it in a simple way, >>>> because Web2py uses its own mechanism to store and retrieve files and >>>> changse file's name. So in each of these tables I store the following >>>> fields: >>>> Field('f_invoice_file_path', type='string') >>>> Field('f_invoice_file', 'upload') >>>> >>>> >>>> >>>> what I wanted to do is something like this: >>>> >>>> def on_before_insert_invoice(fields, id): >>>> db(db.t_invoice.id == id).update( >>>> f_invoice_file=fields['f_invoice_file_path'] >>>> ) >>>> db.t_invoice._before_insert.append( >>>> on_before_insert_invoice >>>> ) >>>> >>>> , here actually *fields* contains a list of tuples in following format >>>> (field, value) so I had to iterate over it to find fields[ >>>> 'f_invoice_file_path'], I just omitted this part for brevity. >>>> >>>> , but I get following error and most likely it is not the proper way to >>>> do that: >>>> >>>> *** RuntimeError: Unable to handle upload >>>> >>>> Note that the field: >>>> >>>> Field('f_invoice_file_path', type='string') >>>> >>>> is saved correctly, I just need somehow to make upload field point to >>>> that location. The next weird thing is that variable *fields* doesn't >>>> contain field Field('f_invoice_file', 'upload') >>>> , even though I added it to the model, settings.migrate is set to True, >>>> and server has been restarted. >>>> >>>> How can I do it? >>>> >>>> >>>> >>>> >>>> >>>> >>>> >>>> -- Resources: - http://web2py.com - http://web2py.com/book (Documentation) - http://github.com/web2py/web2py (Source code) - https://code.google.com/p/web2py/issues/list (Report Issues) --- 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/d/optout.