- Timestamp:
- 29 May 2011, 09:23:30 (13 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
main/waeup.sirp/trunk/src/waeup/sirp/university/coursecontainer.py
r5005 r6216 3 3 import grok 4 4 from zope.interface import implementedBy 5 from zope.component.interfaces import IFactory 5 from zope.component.interfaces import IFactory, ComponentLookupError 6 from zope.catalog.interfaces import ICatalog 7 from zope.component import getUtility 6 8 from waeup.sirp.university.interfaces import ICourseContainer, ICourse 7 9 … … 17 19 if not ICourse.providedBy(course): 18 20 raise TypeError('CourseContainers contain only ICourse instances') 21 try: 22 cat = getUtility(ICatalog, name='courses_catalog') 23 except ComponentLookupError: 24 # catalog not available. This might happen during tests. 25 self[course.code] = course 26 return 'Course added (for tests only).' 27 results = list(cat.searchResults(code=(course.code,course.code))) 28 if results: 29 dep = results[0].__parent__.__parent__.longtitle() 30 fac = results[0].__parent__.__parent__.__parent__.longtitle() 31 return 'Course exists already in %s / %s.' % (fac,dep) 19 32 self[course.code] = course 20 return 33 return 'Course added.' 21 34 22 35 def clear(self):
Note: See TracChangeset for help on using the changeset viewer.