FacultyContainer **************** Containers for faculties. :Test-Layer: unit Getting a faculty container =========================== We can easily create `FacultyContainers`:: >>> from waeup.university.facultycontainer import FacultyContainer >>> mycontainer = FacultyContainer() Faculty containers provide `IFacultyContainer`: >>> from waeup.interfaces import IFacultyContainer >>> IFacultyContainer.providedBy(mycontainer) True Another way to get a faculty container -- without importing the class -- is via factories. We registered a factory for faculty containers under the name ``waeup.facultycontainer``:: >>> import grok >>> grok.testing.grok('waeup') Now we can ask for an object by calling the appropriate factory: >>> from zope.component import createObject >>> createObject(u'waeup.FacultyContainer') This way we get a thing that implements IFacultyContainer without imports or similar. We can be sure, that the full interface is supported by the FacultyContainer class:: >>> from zope.interface.verify import verifyClass >>> verifyClass(IFacultyContainer, FacultyContainer) True Storing things in faculty containers ==================================== We can, of course, store things in a faculty container. But when we really store an object, then it must be a faculty:: >>> mycontainer.addFaculty(42) Traceback (most recent call last): ... TypeError: FacultyContainers contain only IFaculty instances Okay, so we have to get a faculty first:: >>> from waeup.university.faculty import Faculty >>> myfaculty = Faculty() We can add this faculty to our container:: >>> mycontainer.addFaculty(myfaculty) We get back the key, under which the faculty was stored. It will be some string, but there is no guarantee at all, how this key looks like. It might be a string of integers, a name or whatever; you cannot know before.