source: main/waeup.kofa/trunk/src/waeup/kofa/university/facultiescontainer.py @ 17088

Last change on this file since 17088 was 14511, checked in by Henrik Bettermann, 8 years ago

Add officer name fields do IDepartment and IFaculty. Plugins must be updated!

  • Property svn:eol-style set to native
  • Property svn:keywords set to Id
File size: 2.9 KB
Line 
1## $Id: facultiescontainer.py 14511 2017-02-07 08:33:05Z henrik $
2##
3## Copyright (C) 2011 Uli Fouquet & Henrik Bettermann
4## This program is free software; you can redistribute it and/or modify
5## it under the terms of the GNU General Public License as published by
6## the Free Software Foundation; either version 2 of the License, or
7## (at your option) any later version.
8##
9## This program is distributed in the hope that it will be useful,
10## but WITHOUT ANY WARRANTY; without even the implied warranty of
11## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12## GNU General Public License for more details.
13##
14## You should have received a copy of the GNU General Public License
15## along with this program; if not, write to the Free Software
16## Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17##
18import grok
19import zope.location.location
20from zope.component.interfaces import IFactory
21from zope.interface import implementedBy
22from waeup.kofa.interfaces import IKofaPluggable
23from waeup.kofa.university.interfaces import IFacultiesContainer, IFaculty
24from waeup.kofa.utils.batching import VirtualExportJobContainer
25
26class VirtualFacultiesExportJobContainer(VirtualExportJobContainer):
27    """A virtual export job container for the faculties container.
28    """
29
30class FacultiesContainer(grok.Container):
31    """See interfaces for description.
32    """
33    grok.implements(IFacultiesContainer)
34
35    def traverse(self, name):
36        if name == 'exports':
37            # create a virtual exports container and return it
38            container = VirtualFacultiesExportJobContainer()
39            zope.location.location.located(container, self, 'exports')
40            return container
41        return None
42
43    def addFaculty(self, faculty):
44        if not IFaculty.providedBy(faculty):
45            raise TypeError(
46                'FacultiesContainers contain only IFaculty instances')
47        self[faculty.code] = faculty
48        return
49
50class FacultiesContainerFactory(grok.GlobalUtility):
51    """A factory for faculty containers.
52    """
53    grok.implements(IFactory)
54    grok.name(u'waeup.FacultiesContainer')
55    title = u"Create a new facultiescontainer.",
56    description = u"This factory instantiates new containers for faculties."
57
58    def __call__(self, *args, **kw):
59        return FacultiesContainer(*args, **kw)
60
61    def getInterfaces(self):
62        return implementedBy(FacultiesContainer)
63
64class AcademicsPlugin(grok.GlobalUtility):
65    """A plugin that creates container for faculties inside a university.
66    """
67    grok.implements(IKofaPluggable)
68    grok.name('academics')
69
70    def setup(self, site, name, logger):
71        if 'faculties' in site.keys():
72            logger.warn('Could not create container for faculties in Kofa.')
73            return
74        site['faculties'] = FacultiesContainer()
75        logger.info('Container for faculties created')
76        return
77
78    def update(self, site, name, logger):
79        if not 'faculties' in site.keys():
80            self.setup(site, name, logger)
81
Note: See TracBrowser for help on using the repository browser.