Changeset 4481 for waeup/branches/ulif-rewrite
- Timestamp:
- 29 Jul 2009, 01:51:36 (15 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
waeup/branches/ulif-rewrite/src/waeup/utils/csvimport.py
r4471 r4481 6 6 from waeup.interfaces import IFacultyContainer, IWAeUPCSVImporter 7 7 from waeup.utils.importexport import CSVImporter 8 from zope.component import createObject 8 from zope.app.catalog.interfaces import ICatalog 9 from zope.component import createObject, getUtility 9 10 10 11 # … … 204 205 del row['department_code'] 205 206 206 course = dept.courses[code]207 208 207 cert_code = row['certificate_code'] 209 208 cert = dept.certificates[cert_code] 210 209 del row['certificate_code'] 211 210 211 course = self.getCourse(code) 212 212 213 # Type casts... 213 214 row['core_or_elective'] = toBool(row['core_or_elective']) … … 217 218 return 218 219 220 def getCourse(self, code): 221 """Get the course with code `code`. 222 223 Courses can be anywhere in the site. Therefore we ask the 224 catalog. 225 """ 226 cat = getUtility(ICatalog, name='courses_catalog') 227 result = cat.searchResults(code=(code, code)) 228 if len(result) < 1: 229 raise KeyError('No such course found: %s' % code) 230 231 # We might get more than one result, but this should not 232 # happen, as course codes are supposed to be unique. 233 return list(result)[0] 234 235
Note: See TracChangeset for help on using the changeset viewer.