source: main/waeup.sirp/trunk/src/waeup/sirp/university/certificatecontainer.py @ 6114

Last change on this file since 6114 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
RevLine 
[4289]1"""Containers for certificates.
2"""
3import grok
[5005]4from waeup.sirp.university.interfaces import (
5    ICertificateContainer, ICertificate)
[4289]6from zope.component.interfaces import IFactory
[4365]7from zope.interface import implementedBy
[4289]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
[4366]35    def __call__(self, *args, **kw):
36        return CertificateContainer(*args, **kw)
[4289]37
38    def getInterfaces(self):
39        return implementedBy(CertificateContainer)
Note: See TracBrowser for help on using the repository browser.