[web2py] Re: Dynamic Upload Uploadfolder

2014-12-03 Thread James Burke
Final solution was this: _tables.py def store_file(file, filename=None, path=None): path = path #applications/init/uploads if not os.path.exists(path): os.makedirs(path) pathfilename = os.path.join(path, filename) dest_file = open(pathfilename, 'wb') try:

[web2py] Re: Dynamic Upload Uploadfolder

2014-12-02 Thread Leonel Câmara
There are lots of ways to do this, the easiest is probably to just define the uploadfolder for the field in the controller for workbench creation/update instead of defining your custom store and retrieve. Something like this: def create_workbench(): Form to create a workbench in a given

[web2py] Re: Dynamic Upload Uploadfolder

2014-12-02 Thread James Burke
Thank you Leonel, great idea. Although I'll need to use oncreate/onupdate since I'm using a smartgrid Cheers, -James On Tuesday, December 2, 2014 10:28:49 PM UTC+13, Leonel Câmara wrote: There are lots of ways to do this, the easiest is probably to just define the uploadfolder for the

[web2py] Re: Dynamic Upload Uploadfolder

2014-12-01 Thread James Burke
Any ideas? Cheers On Monday, December 1, 2014 11:46:57 AM UTC+13, Massimo Di Pierro wrote: You cannot do this uploadfolder= lambda r:... But this is a chicken-egg problem. You want r to be the row but the row is not created until after the file is uploaded therefore you cannot specify the

[web2py] Re: Dynamic Upload Uploadfolder

2014-11-30 Thread Massimo Di Pierro
You cannot do this uploadfolder= lambda r:... But this is a chicken-egg problem. You want r to be the row but the row is not created until after the file is uploaded therefore you cannot specify the upload folder as function of something that happens after. Please explain to us in english of

[web2py] Re: Dynamic Upload Uploadfolder

2014-11-30 Thread James Burke
Thank you for your help Massimo. My model is defined as follows: ## Repository db.define_table('repository', Field('name', type='string'), Field('directory', default='applications/init/uploads'), format='%(name)s') ## Workbench - workbenches stored in the repository