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

Last change on this file since 9932 was 8367, checked in by Henrik Bettermann, 13 years ago

Add more roles and reorganize permissions.

Remove grok.require('waeup.manageUniversity') from grok.Container classes.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Id
File size: 2.4 KB
Line 
1## $Id: facultiescontainer.py 8367 2012-05-06 11:19:38Z 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
19from zope.component.interfaces import IFactory
20from zope.interface import implementedBy
21from waeup.kofa.interfaces import IKofaPluggable
22from waeup.kofa.university.interfaces import IFacultiesContainer, IFaculty
23
24class FacultiesContainer(grok.Container):
25    """See interfaces for description.
26    """
27    grok.implements(IFacultiesContainer)
28
29    def addFaculty(self, faculty):
30        if not IFaculty.providedBy(faculty):
31            raise TypeError(
32                'FacultiesContainers contain only IFaculty instances')
33        self[faculty.code] = faculty
34        return
35
36class FacultiesContainerFactory(grok.GlobalUtility):
37    """A factory for faculty containers.
38    """
39    grok.implements(IFactory)
40    grok.name(u'waeup.FacultiesContainer')
41    title = u"Create a new facultiescontainer.",
42    description = u"This factory instantiates new containers for faculties."
43
44    def __call__(self, *args, **kw):
45        return FacultiesContainer(*args, **kw)
46
47    def getInterfaces(self):
48        return implementedBy(FacultiesContainer)
49
50class AcademicsPlugin(grok.GlobalUtility):
51    """A plugin that creates container for faculties inside a university.
52    """
53    grok.implements(IKofaPluggable)
54    grok.name('faculties')
55
56    def setup(self, site, name, logger):
57        if 'faculties' in site.keys():
58            logger.warn('Could not create container for faculties in Kofa.')
59            return
60        site['faculties'] = FacultiesContainer()
61        logger.info('Container for faculties created')
62        return
63
64    def update(self, site, name, logger):
65        if not 'faculties' in site.keys():
66            self.setup(site, name, logger)
67
Note: See TracBrowser for help on using the repository browser.