Changeset 7207 for main/waeup.sirp/trunk/src/waeup/sirp
- Timestamp:
- 26 Nov 2011, 08:54:59 (13 years ago)
- Location:
- main/waeup.sirp/trunk/src/waeup/sirp/university
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
main/waeup.sirp/trunk/src/waeup/sirp/university/certificate.py
r7195 r7207 24 24 from zope.interface import implementedBy 25 25 from waeup.sirp.university.interfaces import ( 26 ICertificate, ICertificateAdd, ICertificateCourse , ICourse)26 ICertificate, ICertificateAdd, ICertificateCourse) 27 27 from waeup.sirp.university.vocabularies import course_levels 28 28 … … 113 113 def getInterfaces(self): 114 114 return implementedBy(CertificateCourse) 115 116 @grok.subscribe(ICourse, grok.IObjectRemovedEvent)117 def handle_course_removed(course, event):118 """If a course is deleted, we make sure that also referrers in a119 certificatecontainer are removed.120 """121 code = course.code122 123 # Find all certificatecourses that refer to given course...124 try:125 cat = getUtility(ICatalog, name='certcourses_catalog')126 except ComponentLookupError:127 # catalog not available. This might happen during tests.128 return129 130 results = cat.searchResults(course_code=(code, code))131 for certcourse in results:132 # Remove that referrer...133 cert = certcourse.__parent__134 cert.delCourseRef(code)135 cert._p_changed = True136 return -
main/waeup.sirp/trunk/src/waeup/sirp/university/course.py
r7195 r7207 19 19 """ 20 20 import grok 21 from zope.catalog.interfaces import ICatalog 21 22 from zope.interface import implementedBy 22 from zope.component.interfaces import IFactory 23 from zope.component import getUtility 24 from zope.component.interfaces import IFactory, ComponentLookupError 23 25 from waeup.sirp.university.interfaces import ICourse, ICourseAdd 24 26 … … 57 59 def getInterfaces(self): 58 60 return implementedBy(Course) 61 62 @grok.subscribe(ICourse, grok.IObjectRemovedEvent) 63 def handle_course_removed(course, event): 64 """If a course is deleted, we make sure that also referrers in a 65 certificatecontainer are removed. 66 """ 67 code = course.code 68 69 # Find all certificatecourses that refer to given course... 70 try: 71 cat = getUtility(ICatalog, name='certcourses_catalog') 72 except ComponentLookupError: 73 # catalog not available. This might happen during tests. 74 return 75 76 results = cat.searchResults(course_code=(code, code)) 77 for certcourse in results: 78 # Remove that referrer... 79 cert = certcourse.__parent__ 80 cert.delCourseRef(code) 81 cert._p_changed = True 82 return
Note: See TracChangeset for help on using the changeset viewer.