Hello
i have 3 tables entities, files and events.
Files table has a _before_delete callback to delete all events of a file in
table events before deleting the file.
table events is to drop events for files and entities so i did not create a
foreign key but instead created in entities and files tables  a uuid field
and in table events a field relatedto where i will save the uuid of the
entity or the file ( is this a good way?)
anyway...
when i delete a file it correctly deletes the events for that file , BUT!!!
i was not expecting that deleting a record in table entities also triggers
the files callback and the callback received the id of the entities deleted

any suggestion?


*******************************************************
db.define_table(
    'entities',
    Field('uuid',length=64,default=lambda:str(uuid.uuid4())),
    ...
)
*********************************************************
b.define_table(
    'files',
    ...
    Field('uuid',length=64,default=lambda:str(uuid.uuid4())),
    Field('entities',db.entities),
 ...
)
def delete_ev(*args):
    uuid=db.ficheiros[args[0].query.second]["uuid"]
    db(db.events.relatedto==uuid).delete()

db.files._before_delete.append(lambda s:delete_ev(s))

**************************************************************
db.define_table(
    'events',
    ....
    Field('relatedto'),

)

-- 
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.

Reply via email to