Changeset 12095 for main/waeup.ikoba/trunk/src/waeup/ikoba/products
- Timestamp:
- 30 Nov 2014, 09:12:44 (10 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
main/waeup.ikoba/trunk/src/waeup/ikoba/products/product.py
r12068 r12095 24 24 from hurry.workflow.interfaces import IWorkflowInfo, IWorkflowState 25 25 from zope.event import notify 26 from zope.catalog.interfaces import ICatalog 26 27 from zope.component import getUtility 27 from zope.component.interfaces import IFactory 28 from zope.component.interfaces import IFactory, ComponentLookupError 28 29 from zope.interface import implementedBy 29 30 from zope.i18n import translate … … 61 62 def getInterfaces(self): 62 63 return implementedBy(Product) 64 65 @grok.subscribe(IProduct, grok.IObjectRemovedEvent) 66 def handle_product_removed(product, event): 67 """If a product is deleted, we make sure that also referrers to 68 customer application objects are removed. 69 """ 70 prodid = product.product_id 71 72 # Find all customer applications that refer to given product... 73 try: 74 cat = getUtility(ICatalog, name='applications_catalog') 75 except ComponentLookupError: 76 # catalog not available. This might happen during tests. 77 return 78 results = cat.searchResults(last_product_id=(prodid, prodid)) 79 for application in results: 80 # Remove that referrer... 81 application.product = None 82 notify(grok.ObjectModifiedEvent(application)) 83 application.customer.__parent__.logger.info( 84 'ObjectRemovedEvent - %s - %s - removed: product' % ( 85 application.customer.customer_id, application.application_id)) 86 return 87
Note: See TracChangeset for help on using the changeset viewer.