Changeset 6216 for main/waeup.sirp/trunk/src/waeup
- Timestamp:
- 29 May 2011, 09:23:30 (14 years ago)
- Location:
- main/waeup.sirp/trunk/src/waeup/sirp
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
main/waeup.sirp/trunk/src/waeup/sirp/browser/pages.py
r6210 r6216 1303 1303 course = createObject(u'waeup.Course') 1304 1304 self.applyData(course, **data) 1305 try: 1306 self.context.courses.addCourse(course) 1307 except KeyError: 1308 self.status = Invalid('The code chosen already exists ' 1309 'in the database') 1310 return 1311 except DuplicationError: 1312 self.status = Invalid('The code chosen already exists ' 1313 'in the database') 1314 return 1305 message = self.context.courses.addCourse(course) 1306 self.flash(message) 1315 1307 self.redirect(self.url(self.context, u'@@manage')+'#tab-2') 1316 1308 -
main/waeup.sirp/trunk/src/waeup/sirp/university/certificatecontainer.py
r6213 r6216 4 4 from waeup.sirp.university.interfaces import ( 5 5 ICertificateContainer, ICertificate) 6 from zope.component.interfaces import IFactory 6 from zope.component.interfaces import IFactory, ComponentLookupError 7 7 from zope.catalog.interfaces import ICatalog 8 8 from zope.component import getUtility … … 19 19 raise TypeError('CertificateContainers contain only ' 20 20 'ICertificate instances') 21 cat = getUtility(ICatalog, name='certificates_catalog') 21 try: 22 cat = getUtility(ICatalog, name='certificates_catalog') 23 except ComponentLookupError: 24 # catalog not available. This might happen during tests. 25 self[certificate.code] = certificate 26 return 'Certificate added (for tests only).' 22 27 results = list(cat.searchResults(code=(certificate.code,certificate.code))) 23 28 if results: -
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.