## $Id: facultycontainer.py 7195 2011-11-25 07:34:07Z henrik $ ## ## Copyright (C) 2011 Uli Fouquet & Henrik Bettermann ## This program is free software; you can redistribute it and/or modify ## it under the terms of the GNU General Public License as published by ## the Free Software Foundation; either version 2 of the License, or ## (at your option) any later version. ## ## This program is distributed in the hope that it will be useful, ## but WITHOUT ANY WARRANTY; without even the implied warranty of ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ## GNU General Public License for more details. ## ## You should have received a copy of the GNU General Public License ## along with this program; if not, write to the Free Software ## Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA ## import grok from zope.component.interfaces import IFactory from zope.interface import implementedBy from waeup.sirp.interfaces import IWAeUPSIRPPluggable from waeup.sirp.university.interfaces import IFacultyContainer, IFaculty class FacultyContainer(grok.Container): """See interfaces for description. """ grok.implements(IFacultyContainer) grok.require('waeup.manageUniversity') def addFaculty(self, faculty): if not IFaculty.providedBy(faculty): raise TypeError('FacultyContainers contain only IFaculty instances') self[faculty.code] = faculty return class FacultyContainerFactory(grok.GlobalUtility): """A factory for faculty containers. """ grok.implements(IFactory) grok.name(u'waeup.FacultyContainer') title = u"Create a new faculty container.", description = u"This factory instantiates new faculty containers." def __call__(self, *args, **kw): return FacultyContainer(*args, **kw) def getInterfaces(self): return implementedBy(FacultyContainer) class AcademicsPlugin(grok.GlobalUtility): """A plugin that creates a faculty container inside a university. """ grok.implements(IWAeUPSIRPPluggable) grok.name('faculties') def setup(self, site, name, logger): if 'faculties' in site.keys(): logger.warn('Could not create faculty container in WAeUP SIRP.') return site['faculties'] = FacultyContainer() logger.info('Created faculty container for University') return def update(self, site, name, logger): if not 'faculties' in site.keys(): self.setup(site, name, logger)