Changeset 12095 for main/waeup.ikoba/trunk
- Timestamp:
- 30 Nov 2014, 09:12:44 (10 years ago)
- Location:
- main/waeup.ikoba/trunk/src/waeup/ikoba
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
main/waeup.ikoba/trunk/src/waeup/ikoba/customers/applications.py
r12094 r12095 29 29 from waeup.ikoba.customers.interfaces import ( 30 30 IApplicationsContainer, ICustomerNavigation, 31 IApplication, I CustomersUtils,31 IApplication, IApplicationEdit, ICustomersUtils, 32 32 ) 33 33 from waeup.ikoba.customers.utils import generate_application_id … … 59 59 """This is a customer application baseclass. 60 60 """ 61 grok.implements(IApplication, I CustomerNavigation)61 grok.implements(IApplication, IApplicationEdit, ICustomerNavigation) 62 62 grok.provides(IApplication) 63 63 grok.baseclass() -
main/waeup.ikoba/trunk/src/waeup/ikoba/customers/browser.py
r12094 r12095 51 51 ICustomer, ICustomersContainer, ICustomerRequestPW, ICustomersUtils, 52 52 ICustomerDocument, ICustomerDocumentsContainer, ICustomerCreate, 53 ICustomerPDFDocument, IApplicationsContainer, IApplication 53 ICustomerPDFDocument, IApplicationsContainer, IApplication, IApplicationEdit 54 54 ) 55 55 from waeup.ikoba.customers.catalog import search … … 1183 1183 grok.name('edit') 1184 1184 grok.require('waeup.handleCustomer') 1185 form_fields = grok.AutoFields(IApplicationEdit).omit('last_transition_date') 1185 1186 1186 1187 def update(self): -
main/waeup.ikoba/trunk/src/waeup/ikoba/customers/interfaces.py
r12094 r12095 290 290 title = _(u'Product'), 291 291 source = AppCatProductSource(), 292 required = True, 293 ) 292 required = False, 293 ) 294 295 class IApplicationEdit(IApplication): 296 """Interface for editing application data by customers. 297 298 """ 299 300 product = schema.Choice( 301 title = _(u'Product'), 302 source = AppCatProductSource(), 303 required = True, 304 ) -
main/waeup.ikoba/trunk/src/waeup/ikoba/customers/tests/test_catalog.py
r12094 r12095 16 16 ## Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 17 17 ## 18 import os 18 19 import grok 19 20 import shutil … … 167 168 assert results[0] is self.customer['applications'][self.application_id] 168 169 assert results[0].product is self.product 170 171 def test_product_removal(self): 172 # This test does not only test catalog components, it also ensures 173 # that the product attribute of an application is cleared 174 # but the last_product_id is not. 175 del self.app['products'][self.product_id] 176 self.assertTrue(self.application.product is None) 177 self.assertEqual(self.application.last_product_id, 'SAM') 178 cat = queryUtility(ICatalog, name='applications_catalog') 179 results = cat.searchResults(last_product_id=('SAM', 'SAM')) 180 results = [x for x in results] 181 assert len(results) == 1 182 assert results[0] is self.customer['applications'][self.application_id] 183 assert results[0].product is None 184 # Product removal is being logged in customers.log 185 logfile = os.path.join( 186 self.app['datacenter'].storage, 'logs', 'customers.log') 187 logcontent = open(logfile).read() 188 self.assertTrue( 189 'INFO - system - ObjectRemovedEvent - K1000000 - a101 - removed: product\n' 190 in logcontent) 191 -
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.