Ignore:
Timestamp:
11 Jan 2015, 16:53:38 (10 years ago)
Author:
Henrik Bettermann
Message:

Add handler for document removal. Files must be removed too.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • main/waeup.ikoba/trunk/src/waeup/ikoba/documents/document.py

    r12436 r12442  
    4040    IPDFDocument, IHTMLDocument, IRESTDocument)
    4141
     42
     43@grok.subscribe(IDocument, grok.IObjectRemovedEvent)
     44def handle_document_removed(document, event):
     45    store = getUtility(IExtFileStore)
     46    for filename in document.filenames:
     47        store.deleteFileByContext(document, attr=filename)
     48    return
     49
    4250class Document(grok.Container):
    4351    """This is a document.
     
    4856
    4957    form_fields_interface = None
     58
     59    # Kofa can store any number of files per Document object.
     60    # However, we highly recommend to associate and store
     61    # only one file per Document object. Thus the following
     62    # tuple should contain only a single filename string.
     63    filenames = ()
    5064
    5165    local_roles = [
     
    132146    form_fields_interface = IPDFDocument
    133147
     148    filenames = ('scan.pdf',)
     149
    134150PDFDocument = attrs_to_fields(PDFDocument)
    135151
Note: See TracChangeset for help on using the changeset viewer.