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

Last change on this file since 4971 was 4920, checked in by uli, 15 years ago

Make unit tests run again with the new package layout.

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