source: main/waeup.sirp/trunk/src/waeup/sirp/university/facultycontainer.py @ 5006

Last change on this file since 5006 was 5005, checked in by uli, 15 years ago

Fix references to academics stuff interfaces. This is the first step to make academics stuff pluggable.

  • Property svn:eol-style set to native
File size: 1.3 KB
Line 
1import grok
2from zope.component.interfaces import IFactory
3from zope.interface import implementedBy
4from waeup.sirp.university.interfaces import IFacultyContainer, IFaculty
5
6class FacultyContainer(grok.Container):
7    """See interfaces for description.
8    """
9    grok.implements(IFacultyContainer)
10    grok.require('waeup.manageUniversity')
11
12    def addFaculty(self, faculty):
13        if not IFaculty.providedBy(faculty):
14            raise TypeError('FacultyContainers contain only IFaculty instances')
15        self[faculty.code] = faculty
16        return
17
18    def clear(self):
19        keys = self.keys()
20        for key in keys:
21            del self[key]
22
23    def getName(self, key):
24        if key in self.keys():
25            fac = self[key]
26            prefix = fac.title_prefix
27            prefix = prefix[0].upper() + prefix[1:]
28            return '%s of %s' % (prefix, fac.title)
29           
30class FacultyContainerFactory(grok.GlobalUtility):
31    """A factory for faculty containers.
32    """
33    grok.implements(IFactory)
34    grok.name(u'waeup.FacultyContainer')
35    title = u"Create a new faculty container.",
36    description = u"This factory instantiates new faculty containers."
37
38    def __call__(self, *args, **kw):
39        return FacultyContainer(*args, **kw)
40
41    def getInterfaces(self):
42        return implementedBy(FacultyContainer)
Note: See TracBrowser for help on using the repository browser.