Changeset 4281 for waeup/branches/ulif-rewrite/src
- Timestamp:
- 13 Jun 2009, 17:42:58 (16 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
waeup/branches/ulif-rewrite/src/waeup/university/certificate.py
r3526 r4281 1 """WAeUP portal certificates 2 """ 3 import grok 4 from zope.component.interfaces import IFactory 5 from waeup.interfaces import ICertificate, ICertificateContainer 6 7 class Certificate(grok.Container): 8 """A certificate. 9 """ 10 grok.implements(ICertificate) 11 12 def __init__(self, code='NA'): 13 self.code = code 14 15 class CertificateContainer(grok.Container): 16 """See interfaces for description. 17 """ 18 grok.implements(ICertificateContainer) 19 grok.require('waeup.manageUniversity') 20 21 def addCertificate(self, certificate): 22 if not ICertificate.providedBy(certificate): 23 raise TypeError('CertificateContainers contain only ' 24 'ICertificate instances') 25 self[certificate.code] = certificate 26 return 27 28 def clear(self): 29 keys = self.keys() 30 for key in keys: 31 del self[key] 32 33 class CertificateContainerFactory(grok.GlobalUtility): 34 """A factory for certificate containers. 35 """ 36 grok.implements(IFactory) 37 grok.name(u'waeup.CertificateContainer') 38 title = u"Create a new certificate container.", 39 description = u"This factory instantiates new certificate containers." 40 41 def __call__(self): 42 return CertificateContainer() 43 44 def getInterfaces(self): 45 return implementedBy(CertificateContainer)
Note: See TracChangeset for help on using the changeset viewer.