what are you expecting precisely ? if the problem is that upon record
deletion the corresponding file in the uploads folder is not deleted, mind
that it's a standard behaviour unless in the field you specify
autodelete=True
On Wednesday, February 18, 2015 at 7:41:05 PM UTC+1, Annet wrote:
>
> I' ve got the following function:
>
> def lander_form():
> nodeID = get_ID(auth, session)
>
> folder = 'nodeID' + str(nodeID)
> db.lnd_page.image.uploadfolder =
> os.path.join(request.env.applications_parent, 'applications',
> 'dbmodel', 'static',
> 'uploads', folder)
> db.lnd_page.width.requires = IS_EMPTY_OR(IS_INT_IN_RANGE(0,501,
> error_message='maxWidth is 500 pixels'))
>
> record = db.lnd_page(nodeID=nodeID, id=request.args(1, cast=int))
>
> form = SQLFORM(db.lnd_page, record, deletable=True, showid=False,
> formstyle=bootstrap3, hidden=dict(nodeID=nodeID),
> upload=URL('dbmodel', 'static/uploads', folder,
> args=request.vars.image))
>
> if hasattr(request.vars.image, 'filename'):
> form.vars.imageFilename = request.vars.image.filename
>
> if form.process().accepted:
> if record and form.vars.image__delete:
> file = record.image
>
> os.remove(os.path.join(request.env.applications_parent,'applications',
> 'dbmodel', 'static', 'uploads',
> folder, file))
> record.update_record(image=None, imageFileName=None)
> x_flash(session, None, 'success', 'success')
> redirect(rdrctUrl)
> elif form.errors:
> x_flash(response, None, 'danger', 'error')
> else:
> x_flash(response, None, 'info', 'default')
>
> return locals()
>
> Since checking the form.vars.image__delete and submitting the form did not
> remove the image file, I wrote the code after: if form.process().accepted:
> It does exactly what I intended, however, I don't understand why :-(
>
> Why do I stille have access to record and form after: if
> form.process().accepted:
>
>
> 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.