Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

_before_* callbacks ignores file deletion #320

Open
niphlod opened this issue Dec 29, 2015 · 2 comments
Open

_before_* callbacks ignores file deletion #320

niphlod opened this issue Dec 29, 2015 · 2 comments
Labels

Comments

@niphlod
Copy link
Member

niphlod commented Dec 29, 2015

When the model has defined autodelete=True, and the callback retirns True the register in the dal will not be deleted, but the files in uploads/ desapears.

Model

# -*- coding: utf-8 -*-


def pprint(*args): print args
def bkp_delete( s ):
#    pprint(s) #.select()[0]
    return True    

db.define_table('img',
    Field('image',
        'upload',
        required=True,
        notnull=True,
        autodelete=True,
        uploadseparate=True),
    Field('mdate', 'datetime', notnull=True),
    Field('landmark', 'boolean'))

db.img._before_delete.append( lambda s: bkp_delete(s) ) 

Controller

# -*- coding: utf-8 -*-


def index(): 
    return dict(message="hello from img.py")

def add():
    form = SQLFORM(db.img).process()
    return dict(f=form)

def grid():
    grid=SQLFORM.grid(db.img, user_signature=False)
    return dict(grid=grid)

# add at least 2 registers
# delete 1
# go to de grid, you will see the 2registers.
# try to see the attachment
@niphlod
Copy link
Member Author

niphlod commented Dec 29, 2015

imported from web2py/web2py#1147

@BuhtigithuB
Copy link
Contributor

#330 is a possible duplicate of this issue or somewhat related...

@gi0baro gi0baro added the bug label Apr 19, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants