- Timestamp:
- 11 Dec 2014, 08:12:31 (10 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
main/waeup.ikoba/trunk/src/waeup/ikoba/customers/documents.py
r12169 r12194 25 25 from zope.component.interfaces import IFactory 26 26 from zope.interface import implementedBy 27 from zope.event import notify 27 28 28 29 from waeup.ikoba.image import IkobaImageFile … … 321 322 file_obj.filename, file_obj.data) 322 323 324 325 @grok.subscribe(ICustomerDocument, grok.IObjectRemovedEvent) 326 def handle_document_removed(document, event): 327 """If a document is deleted, we make sure that also referrers to 328 customer contract objects are removed. 329 """ 330 docid = document.document_id 331 332 # Find all customer contracts that refer to given document... 333 try: 334 contracts = document.customer['contracts'].values() 335 except AttributeError: 336 # customer not available. This might happen during tests. 337 return 338 for contract in contracts: 339 # Remove that referrer... 340 #contract.product = None 341 for key, value in contract.__dict__.items(): 342 if key.endswith('_object') and \ 343 getattr(value, 'document_id', None) == docid: 344 setattr(contract, key, None) 345 notify(grok.ObjectModifiedEvent(contract)) 346 contract.customer.__parent__.logger.info( 347 'ObjectRemovedEvent - %s - %s - removed: %s' % ( 348 contract.customer.customer_id, 349 contract.contract_id, 350 document.document_id)) 351 return 352
Note: See TracChangeset for help on using the changeset viewer.