Field(...,uploadfolder="...")

22 views
Skip to first unread message

annet

unread,
Sep 19, 2009, 3:14:36 AM9/19/09
to web2py-users
Does Field(...,uploadfolder="...") make it possible to let every user
have his own upload folder by assigning a variable to uploadfolder
like: in the table definition in my model: Field
(...,uploadfolder=variable) and in the controller: variable="myfolder"

Kind regards,

Annet.

Fran

unread,
Sep 19, 2009, 4:33:19 AM9/19/09
to web2py-users
No, since the models execute before the controllers.

The way I'd do this is to override the default setting within the
controller, something like:

def mycontrollerfunction():
db.table.field.uploadfolder = os.path.join(request.folder,
"uploads/%i" % auth.user.id)
form = crud.create(db.table)
...

Which needs a matching:

def download():
db.table.field.uploadfolder = os.path.join(request.folder,
"uploads/%i" % auth.user.id)
return response.download(request, db)

F

weheh

unread,
Sep 19, 2009, 2:37:50 PM9/19/09
to web2py-users
Fran is correct. The place to specify the uploadfolder is in the
controller (when uploading) and the download function (for
downloading). I just tested out the functionality and it works as
advertised, enabling every user to have his/her own upload folder.
Reply all
Reply to author
Forward
0 new messages