Hi Anthony,
Thanks for your reply.
After reading the parts on download() in chapter 7 and 9 I wrote the
following functions:
def logo():
vertexID = session.vertexID
table.vertexID.default = vertexID
folder = 'vertexID' + str(vertexID)
table.image.uploadfolder = os.path.join('/Users/iannet/Documents/' +
folder)
record = table(vertexID=vertexID)
form = SQLFORM(table, record, deletable=True, showid=False,
upload=URL('image_download', args=request.vars.image))
if form.process().accepted:
if record and form.vars.image__delete:
file = record.image
os.remove(os.path.join('/Users/iannet/Documents/' + folder,
file))
elif form.errors:
get_flash(response, None, 'danger', 'error')
elif not response.flash:
get_flash(response, None, 'info', 'custom')
return dict(form=form)
def image_download():
folder = 'vertexID' + str(session.vertexID)
file_path = os.path.join('/Users/iannet/Documents/' + folder + '/')
return response.stream(open(file_path + request.args(0)))
Are there any improvements to make to this code?
Kind regards,
Annet
--
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 [email protected].
For more options, visit https://groups.google.com/d/optout.