- Timestamp:
- 31 Jul 2009, 06:52:37 (15 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
waeup/branches/ulif-rewrite/src/waeup/university/certificate.txt
r4386 r4489 427 427 428 428 >>> course = newdbroot['mydept'].courses['MYCOURSE'] 429 >>> certcourse = newdbroot['mydept'].certificates['MYCERT']['MYCOURSE ']429 >>> certcourse = newdbroot['mydept'].certificates['MYCERT']['MYCOURSE_100'] 430 430 >>> certcourse.course is course 431 431 True … … 434 434 reflected in the certcourse. 435 435 436 The interesting question now is: what happens to ``mycertcourse`` when437 the referenced course ``mycourse`` is deleted?438 439 Let's have a look:440 441 >>> list(newdbroot['mydept'].certificates['MYCERT'].keys())442 [u'MYCOURSE']443 444 >>> del newdbroot['mydept'].courses['MYCOURSE']445 >>> newdbroot['mydept']._p_changed = True446 >>> transaction.commit()447 >>> list(newdbroot['mydept'].certificates['MYCERT'].keys())448 []449 450 As we can see, the course was also removed from the certificate.451 452 We can of course also remove existing courses from certificates by453 using :meth:`delCourseRef`. This will not remove the same course from454 any course container:455 456 >>> mycourses = newdbroot['mydept'].courses457 >>> mycert = newdbroot['mydept'].certificates['MYCERT']458 >>> mycourses.addCourse(mycourse)459 >>> mycert.addCourseRef(mycourse)460 >>> c1 = mycourses['MYCOURSE']461 >>> c2 = mycert['MYCOURSE'].course462 >>> c1 is c2463 True464 465 >>> mycert.delCourseRef('MYCOURSE')466 467 The certificate now has no ``MYCOURSE`` course anymore, while the468 courses container still has:469 470 >>> 'MYCOURSE' in mycert.keys()471 False472 473 >>> mycourses['MYCOURSE']474 <waeup.university.course.Course object at 0x...>475 476 Clean up:477 478 >>> import os479 >>> os.unlink(dbpath)
Note: See TracChangeset for help on using the changeset viewer.