university.certificatescontainer - Certificates Container Components

Containers for certificates.

class waeup.kofa.university.certificatescontainer.CertificatesContainer[source]

Bases: grokcore.content.components.Container

A storage for certificates.

A CertificatesContainer stores waeup.kofa.university.Certificate instances.

It is a grok.Container basically acting like a standard Python dictionary. That means you can add certificates like items in a normal dictionary and also get certificates by using values(), keys(), and items().

This container type is picky about its contents: only real certificates can be stored here and each new certificate must provide a unique code. See addCertificate() for details.

Each CertificatesContainer provides ICertificatesContainer.

__doc__ = 'A storage for certificates.\n\n A :class:`CertificatesContainer` stores\n :class:`waeup.kofa.university.Certificate` instances.\n\n It is a :class:`grok.Container` basically acting like a standard\n Python dictionary. That means you can add certificates like items\n in a normal dictionary and also get certificates by using\n :meth:`values`, :meth:`keys`, and :meth:`items`.\n\n This container type is picky about its contents: only real\n certificates can be stored here and each new certificate must\n provide a unique `code`. See :meth:`addCertificate` for details.\n\n Each :class:`CertificatesContainer` provides\n :class:`ICertificatesContainer`.\n '
__implemented__ = <implementedBy waeup.kofa.university.certificatescontainer.CertificatesContainer>
__module__ = 'waeup.kofa.university.certificatescontainer'
__provides__

Special descriptor for class __provides__

The descriptor caches the implementedBy info, so that we can get declarations for objects without instance-specific interfaces a bit quicker.

For example:

>>> from zope.interface import Interface
>>> class IFooFactory(Interface):
...     pass
>>> class IFoo(Interface):
...     pass
>>> class C(object):
...     implements(IFoo)
...     classProvides(IFooFactory)
>>> [i.getName() for i in C.__provides__]
['IFooFactory']
>>> [i.getName() for i in C().__provides__]
['IFoo']
__setitem__(name, certificate)[source]

Insert certificate with name as key into container.

The certificate must be an object implementing waeup.kofa.university.interfaces.ICertificate. If not, a TypeError is raised.

If the certificate code does not equal name a ValueError is raised.

If the code attribute of certificate is already in use by another certificate stored in the local site (waeup.kofa.app.University instance), then a waeup.kofa.interfaces.DuplicationError will be raised.

If name is already used as a key, a KeyError will be raised.

addCertificate(certificate)[source]

Add certificate to the container.

The certificate must be an object implementing waeup.kofa.university.interfaces.ICertificate. If not, a TypeError is raised.

The certificate will be stored in the container with its code attribute as key. If this key is already used for another certificate stored in the local site (waeup.kofa.app.University instance), then a waeup.kofa.interfaces.DuplicationError will be raised.

clear()[source]

Remove all contents from the certificate container.

This methods is pretty fast and optimized. Use it instead of removing all items manually yourself.

class waeup.kofa.university.certificatescontainer.CertificatesContainerFactory[source]

Bases: grokcore.component.components.GlobalUtility

A factory for certificate containers.

__call__(*args, **kw)[source]
__doc__ = 'A factory for certificate containers.\n '
__implemented__ = <implementedBy waeup.kofa.university.certificatescontainer.CertificatesContainerFactory>
__module__ = 'waeup.kofa.university.certificatescontainer'
__provides__

Special descriptor for class __provides__

The descriptor caches the implementedBy info, so that we can get declarations for objects without instance-specific interfaces a bit quicker.

For example:

>>> from zope.interface import Interface
>>> class IFooFactory(Interface):
...     pass
>>> class IFoo(Interface):
...     pass
>>> class C(object):
...     implements(IFoo)
...     classProvides(IFooFactory)
>>> [i.getName() for i in C.__provides__]
['IFooFactory']
>>> [i.getName() for i in C().__provides__]
['IFoo']
description = u'This factory instantiates new containers for certificates.'
getInterfaces()[source]
title = (u'Create a new container for certificates.',)