In a model I defined a table:
db.define_table('image',
db.Field
('bedrijf',db.bedrijf,default='',notnull=True,ondelete='CASCADE'),
db.Field('imagepositie',db.imagepositie,default='',notnull=True),
db.Field
('imagefile',type='upload',deletable=True,default='',notnull=True),
db.Field('posted_on',type='datetime'),
db.Field('modified_on',type='datetime'),
migrate='image.table')
In the controller I defined two functions:
@auth.requires_membership('site_manager')
def crud_image():
response.functionname=T('CRUD image')
db.image.bedrijf.writable=False
db.image.bedrijf.default=auth.user.bedrijf
form=create_form(db.image)
records=db((db.image.bedrijf==auth.user.bedrijf)&
(db.image.imagepositie==db.imagepositie.id))\
.select(db.image.ALL,db.imagepositie.positie)
return dict(form=form,records=records)
@auth.requires_membership('site_manager')
def update_image():
response.view='core/update.html'
db.image.bedrijf.writable=False
record=db.image[request.args[0]]
if not record or not record.bedrijf==auth.user.bedrijf:
redirect(URL(r=request,f='crud_image'))
form=update_form(db.image,record,'crud_image')
return dict(form=form)
Creating, retrieving and updating an image works, but when I delete a
record the image isn't deleted from the uploads folder. What property
do I have to set to delete the image file from the uploads folder.
I came across an example in which the developer stores the image in
the database in a blob field, what are the pros and cons of storing
the image in the uploads folder versus storing the image in the
database.
Kind regards,
Annet.
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"web2py Web Framework" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/web2py?hl=en
-~----------~----~----~----~------~----~------~--~---