source: main/waeup.sirp/branches/ulif-fasttables/src/waeup/sirp/university/certificatecontainer.py @ 11107

Last change on this file since 11107 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.

File size: 1.2 KB
Line 
1"""Containers for certificates.
2"""
3import grok
4from waeup.sirp.university.interfaces import (
5    ICertificateContainer, ICertificate)
6from zope.component.interfaces import IFactory
7from zope.interface import implementedBy
8
9class CertificateContainer(grok.Container):
10    """See interfaces for description.
11    """
12    grok.implements(ICertificateContainer)
13    grok.require('waeup.manageUniversity')
14
15    def addCertificate(self, certificate):
16        if not ICertificate.providedBy(certificate):
17            raise TypeError('CertificateContainers contain only '
18                            'ICertificate instances')
19        self[certificate.code] = certificate
20        return
21
22    def clear(self):
23        keys = self.keys()
24        for key in keys:
25            del self[key]
26
27class CertificateContainerFactory(grok.GlobalUtility):
28    """A factory for certificate containers.
29    """
30    grok.implements(IFactory)
31    grok.name(u'waeup.CertificateContainer')
32    title = u"Create a new certificate container.",
33    description = u"This factory instantiates new certificate containers."
34
35    def __call__(self, *args, **kw):
36        return CertificateContainer(*args, **kw)
37
38    def getInterfaces(self):
39        return implementedBy(CertificateContainer)
Note: See TracBrowser for help on using the repository browser.