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

Last change on this file since 6447 was 5988, checked in by Henrik Bettermann, 14 years ago

Implement title_prefix vocabulary. Remove redundant getName method and replace by the longtitle property.

  • Property svn:eol-style set to native
File size: 1.7 KB
RevLine 
[3526]1import grok
[4789]2from zope.component.interfaces import IFactory
3from zope.interface import implementedBy
[5014]4from waeup.sirp.interfaces import IWAeUPSIRPPluggable
[5005]5from waeup.sirp.university.interfaces import IFacultyContainer, IFaculty
[3526]6
[4789]7class FacultyContainer(grok.Container):
8    """See interfaces for description.
9    """
10    grok.implements(IFacultyContainer)
11    grok.require('waeup.manageUniversity')
12
13    def addFaculty(self, faculty):
14        if not IFaculty.providedBy(faculty):
15            raise TypeError('FacultyContainers contain only IFaculty instances')
16        self[faculty.code] = faculty
17        return
18
19    def clear(self):
20        keys = self.keys()
21        for key in keys:
22            del self[key]
23
24class FacultyContainerFactory(grok.GlobalUtility):
25    """A factory for faculty containers.
26    """
27    grok.implements(IFactory)
28    grok.name(u'waeup.FacultyContainer')
29    title = u"Create a new faculty container.",
30    description = u"This factory instantiates new faculty containers."
31
[4976]32    def __call__(self, *args, **kw):
33        return FacultyContainer(*args, **kw)
[4789]34
35    def getInterfaces(self):
36        return implementedBy(FacultyContainer)
[5014]37
38class AcademicsPlugin(grok.GlobalUtility):
[5070]39    """A plugin that creates a faculty container inside a university.
[5014]40    """
41    grok.implements(IWAeUPSIRPPluggable)
[5070]42    grok.name('faculties')
[5014]43
[5070]44    def setup(self, site, name, logger):
45        if 'faculties' in site.keys():
46            logger.warn('Could not create faculty container in WAeUP SIRP.')
47            return
48        site['faculties'] = FacultyContainer()
49        logger.info('Created faculty container for University')
50        return
[5014]51
[5070]52    def update(self, site, name, logger):
53        pass
Note: See TracBrowser for help on using the repository browser.