Changeset 7333 for main/waeup.sirp/trunk/src/waeup/sirp/university
- Timestamp:
- 12 Dec 2011, 07:01:54 (13 years ago)
- Location:
- main/waeup.sirp/trunk/src/waeup/sirp/university
- Files:
-
- 8 edited
- 9 moved
Legend:
- Unmodified
- Added
- Removed
-
main/waeup.sirp/trunk/src/waeup/sirp/university/__init__.py
r7137 r7333 1 1 # Make this a package. 2 2 from waeup.sirp.university.course import Course 3 from waeup.sirp.university.course container import CourseContainer3 from waeup.sirp.university.coursescontainer import CoursesContainer 4 4 from waeup.sirp.university.faculty import Faculty 5 from waeup.sirp.university.facult ycontainer import FacultyContainer5 from waeup.sirp.university.facultiescontainer import FacultiesContainer 6 6 __all__ = ( 7 'Course', 'Course Container', 'Faculty', 'FacultyContainer')7 'Course', 'CoursesContainer', 'Faculty', 'FacultiesContainer') -
main/waeup.sirp/trunk/src/waeup/sirp/university/api.txt
r5978 r7333 15 15 16 16 certificate.txt 17 certificate container.txt17 certificatescontainer.txt 18 18 course.txt 19 course container.txt19 coursescontainer.txt 20 20 department.txt 21 21 faculty.txt 22 facult ycontainer.txt22 facultiescontainer.txt 23 23 24 24 Additional infos about the referrers of courses and how they are -
main/waeup.sirp/trunk/src/waeup/sirp/university/batching.py
r7195 r7333 28 28 from waeup.sirp.interfaces import IBatchProcessor 29 29 from waeup.sirp.university.interfaces import ( 30 IFacult yContainer, IFaculty, ICourse, IDepartment, ICertificate,30 IFacultiesContainer, IFaculty, ICourse, IDepartment, ICertificate, 31 31 ICertificateCourse) 32 32 from waeup.sirp.utils.batching import BatchProcessor -
main/waeup.sirp/trunk/src/waeup/sirp/university/certificatescontainer.py
r7331 r7333 25 25 from waeup.sirp.interfaces import DuplicationError 26 26 from waeup.sirp.university.interfaces import ( 27 ICertificate Container, ICertificate)27 ICertificatesContainer, ICertificate) 28 28 29 class Certificate Container(grok.Container):29 class CertificatesContainer(grok.Container): 30 30 """A storage for certificates. 31 31 32 A :class:`Certificate Container` stores32 A :class:`CertificatesContainer` stores 33 33 :class:`waeup.sirp.university.Certificate` instances. 34 34 … … 42 42 provide a unique `code`. See :meth:`addCertificate` for details. 43 43 44 Each :class:`Certificate Container` provides45 :class:`ICertificate Container`.44 Each :class:`CertificatesContainer` provides 45 :class:`ICertificatesContainer`. 46 46 """ 47 grok.implements(ICertificate Container)47 grok.implements(ICertificatesContainer) 48 48 grok.require('waeup.manageUniversity') 49 49 … … 67 67 """ 68 68 if not ICertificate.providedBy(certificate): 69 raise TypeError('Certificate Containers contain only '69 raise TypeError('CertificatesContainers contain only ' 70 70 'ICertificate instances') 71 71 … … 86 86 # No catalog, then this addition won't do harm to anything. 87 87 pass 88 super(Certificate Container, self).__setitem__(name, certificate)88 super(CertificatesContainer, self).__setitem__(name, certificate) 89 89 90 90 def addCertificate(self, certificate): … … 117 117 del self.__dict__['_BTreeContainer__len'] 118 118 119 class Certificate ContainerFactory(grok.GlobalUtility):119 class CertificatesContainerFactory(grok.GlobalUtility): 120 120 """A factory for certificate containers. 121 121 """ 122 122 grok.implements(IFactory) 123 grok.name(u'waeup.Certificate Container')124 title = u"Create a new c ertificate container.",125 description = u"This factory instantiates new c ertificate containers."123 grok.name(u'waeup.CertificatesContainer') 124 title = u"Create a new container for certificates.", 125 description = u"This factory instantiates new containers for certificates." 126 126 127 127 def __call__(self, *args, **kw): 128 return Certificate Container(*args, **kw)128 return CertificatesContainer(*args, **kw) 129 129 130 130 def getInterfaces(self): 131 return implementedBy(Certificate Container)131 return implementedBy(CertificatesContainer) -
main/waeup.sirp/trunk/src/waeup/sirp/university/certificatescontainer.txt
r7331 r7333 1 :mod:`waeup.sirp.university.certificate container` -- Certificate containers2 *************************************************************************** 1 :mod:`waeup.sirp.university.certificatescontainer` -- Certificate containers 2 **************************************************************************** 3 3 4 .. module:: waeup.sirp.university.certificate container4 .. module:: waeup.sirp.university.certificatescontainer 5 5 6 6 Containers for certificates. … … 13 13 ======================================= 14 14 15 :class:`Certificate Container`16 ----------------------------- 15 :class:`CertificatesContainer` 16 ------------------------------ 17 17 18 .. class:: Certificate Container()18 .. class:: CertificatesContainer() 19 19 20 20 Create a certificate container instance. 21 21 22 .. attribute:: grok.implements(ICertificate Container)22 .. attribute:: grok.implements(ICertificatesContainer) 23 23 24 24 .. attribute:: grok.require('waeup.manageUniversity') 25 25 26 :class:`Certificate Container` instances are instances of26 :class:`CertificatesContainer` instances are instances of 27 27 :class:`grok.Container` that hold and manage instances of 28 28 :class:`waeup.sirp.university.certificate.Certificate`. 29 29 30 >>> from waeup.sirp.university.certificate container import CertificateContainer31 >>> mycontainer = Certificate Container()30 >>> from waeup.sirp.university.certificatescontainer import CertificatesContainer 31 >>> mycontainer = CertificatesContainer() 32 32 >>> mycontainer 33 <waeup.sirp.university.certificate container.CertificateContainer object at 0x...>33 <waeup.sirp.university.certificatescontainer.CertificatesContainer object at 0x...> 34 34 35 Certificate containers provide `ICertificate Container`:35 Certificate containers provide `ICertificatesContainer`: 36 36 37 >>> from waeup.sirp.university.interfaces import ICertificate Container38 >>> ICertificate Container.providedBy(mycontainer)37 >>> from waeup.sirp.university.interfaces import ICertificatesContainer 38 >>> ICertificatesContainer.providedBy(mycontainer) 39 39 True 40 40 41 41 We can be sure, that the full interface is supported by the 42 Certificate Container class:42 CertificatesContainer class: 43 43 44 44 >>> from zope.interface.verify import verifyClass 45 >>> verifyClass(ICertificate Container, CertificateContainer)45 >>> verifyClass(ICertificatesContainer, CertificatesContainer) 46 46 True 47 47 48 As normal ``grok.Container``, :class:`Certificate Container` instances48 As normal ``grok.Container``, :class:`CertificatesContainer` instances 49 49 can be used like dicts: 50 50 … … 59 59 :class:`waeup.sirp.university.certificate.Certificate`: 60 60 61 >>> from waeup.sirp.university.certificate container import (62 ... Certificate Container)63 >>> mycontainer = Certificate Container()61 >>> from waeup.sirp.university.certificatescontainer import ( 62 ... CertificatesContainer) 63 >>> mycontainer = CertificatesContainer() 64 64 >>> mycontainer.addCertificate('blah') 65 65 Traceback (most recent call last): 66 66 ... 67 TypeError: Certificate Containers contain only ICertificate instances67 TypeError: CertificatesContainers contain only ICertificate instances 68 68 69 69 The key of added items is the ``code`` attribute: … … 89 89 ========= 90 90 91 :class:`Certificate ContainerFactory`92 ------------------------------------ 91 :class:`CertificatesContainerFactory` 92 ------------------------------------- 93 93 94 .. class:: Certificate ContainerFactory()94 .. class:: CertificatesContainerFactory() 95 95 96 .. attribute:: grok.name(u'waeup.Certificate Container')96 .. attribute:: grok.name(u'waeup.CertificatesContainer') 97 97 98 98 .. attribute:: grok.implements(IFactory) 99 99 100 A named utility to deliver new instances of :class:`Certificate Container`100 A named utility to deliver new instances of :class:`CertificatesContainer` 101 101 without the need to import the implementation before: 102 102 103 103 >>> from zope.component import createObject 104 >>> mycertificate container = createObject(u'waeup.CertificateContainer')105 >>> mycertificate container106 <waeup.sirp.university.certificate container.CertificateContainer object at 0x...>104 >>> mycertificatescontainer = createObject(u'waeup.CertificatesContainer') 105 >>> mycertificatescontainer 106 <waeup.sirp.university.certificatescontainer.CertificatesContainer object at 0x...> 107 107 108 108 The factory complies with the specifications from the … … 111 111 >>> from zope.interface.verify import verifyClass 112 112 >>> from zope.component.interfaces import IFactory 113 >>> from waeup.sirp.university.certificate container import (114 ... Certificate ContainerFactory)115 >>> verifyClass(IFactory, Certificate ContainerFactory)113 >>> from waeup.sirp.university.certificatescontainer import ( 114 ... CertificatesContainerFactory) 115 >>> verifyClass(IFactory, CertificatesContainerFactory) 116 116 True 117 117 … … 119 119 object from the factory: 120 120 121 >>> certificate container_factory = CertificateContainerFactory()122 >>> certificate container_factory.getInterfaces()123 <implementedBy waeup.sirp.university.certificate container.CertificateContainer>121 >>> certificatescontainer_factory = CertificatesContainerFactory() 122 >>> certificatescontainer_factory.getInterfaces() 123 <implementedBy waeup.sirp.university.certificatescontainer.CertificatesContainer> 124 124 125 125 … … 130 130 ------------------------------- 131 131 132 We can easily create `Certificate Containers`:132 We can easily create `CertificatesContainers`: 133 133 134 >>> from waeup.sirp.university.certificate container import CertificateContainer135 >>> mycontainer = Certificate Container()134 >>> from waeup.sirp.university.certificatescontainer import CertificatesContainer 135 >>> mycontainer = CertificatesContainer() 136 136 137 137 138 138 Another way to get a certificate container -- without importing the 139 139 class -- is via factories. We registered a factory for certificate 140 containers under the name ``waeup.Certificate Container``. Now we can140 containers under the name ``waeup.CertificatesContainer``. Now we can 141 141 ask for an object by calling the appropriate factory: 142 142 143 143 >>> from zope.component import createObject 144 >>> createObject(u'waeup.Certificate Container')145 <waeup.sirp.university.certificate container.CertificateContainer object at 0x...>144 >>> createObject(u'waeup.CertificatesContainer') 145 <waeup.sirp.university.certificatescontainer.CertificatesContainer object at 0x...> 146 146 147 This way we get a thing that implements ICertificate Container without147 This way we get a thing that implements ICertificatesContainer without 148 148 imports or similar. 149 149 -
main/waeup.sirp/trunk/src/waeup/sirp/university/course.py
r7207 r7333 63 63 def handle_course_removed(course, event): 64 64 """If a course is deleted, we make sure that also referrers in a 65 certificate container are removed.65 certificatescontainer are removed. 66 66 """ 67 67 code = course.code -
main/waeup.sirp/trunk/src/waeup/sirp/university/coursescontainer.py
r7331 r7333 24 24 from zope.component import queryUtility 25 25 from waeup.sirp.interfaces import DuplicationError 26 from waeup.sirp.university.interfaces import ICourse Container, ICourse26 from waeup.sirp.university.interfaces import ICoursesContainer, ICourse 27 27 28 class Course Container(grok.Container):28 class CoursesContainer(grok.Container): 29 29 """See interfaces for description. 30 30 """ 31 grok.implements(ICourse Container)31 grok.implements(ICoursesContainer) 32 32 grok.require('waeup.manageUniversity') 33 33 34 34 def __setitem__(self, name, course): 35 """See corresponding docstring in certificate container.py.35 """See corresponding docstring in certificatescontainer.py. 36 36 """ 37 37 if not ICourse.providedBy(course): 38 raise TypeError('Course Containers contain only '38 raise TypeError('CoursesContainers contain only ' 39 39 'ICourse instances') 40 40 … … 55 55 # No catalog, then this addition won't do harm to anything. 56 56 pass 57 super(Course Container, self).__setitem__(name, course)57 super(CoursesContainer, self).__setitem__(name, course) 58 58 59 59 def addCourse(self, course): 60 """See corresponding docstring in certificate container.py.60 """See corresponding docstring in certificatescontainer.py. 61 61 """ 62 62 self[getattr(course, 'code', None)] = course 63 63 64 64 def clear(self): 65 """See corresponding docstring and comments in certificate container.py.65 """See corresponding docstring and comments in certificatescontainer.py. 66 66 """ 67 67 self._SampleContainer__data.clear() 68 68 del self.__dict__['_BTreeContainer__len'] 69 69 70 class Course ContainerFactory(grok.GlobalUtility):70 class CoursesContainerFactory(grok.GlobalUtility): 71 71 """A factory for course containers. 72 72 """ 73 73 grok.implements(IFactory) 74 grok.name(u'waeup.Course Container')75 title = u"Create a new co urse container.",76 description = u"This factory instantiates new co urse containers."74 grok.name(u'waeup.CoursesContainer') 75 title = u"Create a new container for courses.", 76 description = u"This factory instantiates new containers for courses." 77 77 78 78 def __call__(self, *args, **kw): 79 return Course Container(*args, **kw)79 return CoursesContainer(*args, **kw) 80 80 81 81 def getInterfaces(self): 82 return implementedBy(Course Container)82 return implementedBy(CoursesContainer) -
main/waeup.sirp/trunk/src/waeup/sirp/university/coursescontainer.txt
r7331 r7333 1 :mod:`waeup.sirp.university.course container` -- Course containers2 ***************************************************************** 1 :mod:`waeup.sirp.university.coursescontainer` -- Course containers 2 ****************************************************************** 3 3 4 .. module:: waeup.sirp.university.course container4 .. module:: waeup.sirp.university.coursescontainer 5 5 6 6 Containers for courses. … … 13 13 ======================================= 14 14 15 :class:`Course Container`16 ------------------------ 15 :class:`CoursesContainer` 16 ------------------------- 17 17 18 .. class:: Course Container()18 .. class:: CoursesContainer() 19 19 20 20 Create a course container instance. 21 21 22 .. attribute:: grok.implements(ICourse Container)22 .. attribute:: grok.implements(ICoursesContainer) 23 23 24 24 .. attribute:: grok.require('waeup.manageUniversity') 25 25 26 :class:`Course Container` instances are instances of26 :class:`CoursesContainer` instances are instances of 27 27 :class:`grok.Container` that hold and manage instances of 28 28 :class:`waeup.sirp.university.course.Course`. 29 29 30 >>> from waeup.sirp.university.course container import CourseContainer31 >>> mycontainer = Course Container()30 >>> from waeup.sirp.university.coursescontainer import CoursesContainer 31 >>> mycontainer = CoursesContainer() 32 32 >>> mycontainer 33 <waeup.sirp.university.course container.CourseContainer object at 0x...>33 <waeup.sirp.university.coursescontainer.CoursesContainer object at 0x...> 34 34 35 Course containers provide `ICourse Container`:35 Course containers provide `ICoursesContainer`: 36 36 37 >>> from waeup.sirp.university.interfaces import ICourse Container38 >>> ICourse Container.providedBy(mycontainer)37 >>> from waeup.sirp.university.interfaces import ICoursesContainer 38 >>> ICoursesContainer.providedBy(mycontainer) 39 39 True 40 40 41 41 We can be sure, that the full interface is supported by the 42 Course Container class:42 CoursesContainer class: 43 43 44 44 >>> from zope.interface.verify import verifyClass 45 >>> verifyClass(ICourse Container, CourseContainer)45 >>> verifyClass(ICoursesContainer, CoursesContainer) 46 46 True 47 47 48 As normal ``grok.Container``, :class:`Course Container` instances48 As normal ``grok.Container``, :class:`CoursesContainer` instances 49 49 can be used like dicts: 50 50 … … 59 59 :class:`waeup.sirp.university.course.Course`: 60 60 61 >>> from waeup.sirp.university.course container import CourseContainer62 >>> mycontainer = Course Container()61 >>> from waeup.sirp.university.coursescontainer import CoursesContainer 62 >>> mycontainer = CoursesContainer() 63 63 >>> mycontainer.addCourse('blah') 64 64 Traceback (most recent call last): 65 65 ... 66 TypeError: Course Containers contain only ICourse instances66 TypeError: CoursesContainers contain only ICourse instances 67 67 68 68 The key of added items is the ``code`` attribute: … … 88 88 ========= 89 89 90 :class:`Course ContainerFactory`91 ------------------------------- 90 :class:`CoursesContainerFactory` 91 -------------------------------- 92 92 93 .. class:: Course ContainerFactory()93 .. class:: CoursesContainerFactory() 94 94 95 .. attribute:: grok.name(u'waeup.Course Container')95 .. attribute:: grok.name(u'waeup.CoursesContainer') 96 96 97 97 .. attribute:: grok.implements(IFactory) 98 98 99 A named utility to deliver new instances of :class:`Course Container`99 A named utility to deliver new instances of :class:`CoursesContainer` 100 100 without the need to import the implementation before: 101 101 102 102 >>> from zope.component import createObject 103 >>> mycourse container = createObject(u'waeup.CourseContainer')104 >>> mycourse container105 <waeup.sirp.university.course container.CourseContainer object at 0x...>103 >>> mycoursescontainer = createObject(u'waeup.CoursesContainer') 104 >>> mycoursescontainer 105 <waeup.sirp.university.coursescontainer.CoursesContainer object at 0x...> 106 106 107 107 The factory complies with the specifications from the … … 110 110 >>> from zope.interface.verify import verifyClass 111 111 >>> from zope.component.interfaces import IFactory 112 >>> from waeup.sirp.university.course container import CourseContainerFactory113 >>> verifyClass(IFactory, Course ContainerFactory)112 >>> from waeup.sirp.university.coursescontainer import CoursesContainerFactory 113 >>> verifyClass(IFactory, CoursesContainerFactory) 114 114 True 115 115 … … 117 117 object from the factory: 118 118 119 >>> course container_factory = CourseContainerFactory()120 >>> course container_factory.getInterfaces()121 <implementedBy waeup.sirp.university.course container.CourseContainer>119 >>> coursescontainer_factory = CoursesContainerFactory() 120 >>> coursescontainer_factory.getInterfaces() 121 <implementedBy waeup.sirp.university.coursescontainer.CoursesContainer> 122 122 123 123 … … 128 128 -------------------------- 129 129 130 We can easily create `Course Containers`:130 We can easily create `CoursesContainers`: 131 131 132 >>> from waeup.sirp.university.course container import CourseContainer133 >>> mycontainer = Course Container()132 >>> from waeup.sirp.university.coursescontainer import CoursesContainer 133 >>> mycontainer = CoursesContainer() 134 134 135 135 136 136 Another way to get a course container -- without importing the class 137 137 -- is via factories. We registered a factory for course containers 138 under the name ``waeup.Course Container``. Now we can ask for an object138 under the name ``waeup.CoursesContainer``. Now we can ask for an object 139 139 by calling the appropriate factory: 140 140 141 141 >>> from zope.component import createObject 142 >>> createObject(u'waeup.Course Container')143 <waeup.sirp.university.course container.CourseContainer object at 0x...>142 >>> createObject(u'waeup.CoursesContainer') 143 <waeup.sirp.university.coursescontainer.CoursesContainer object at 0x...> 144 144 145 This way we get a thing that implements ICourse Container without145 This way we get a thing that implements ICoursesContainer without 146 146 imports or similar. 147 147 -
main/waeup.sirp/trunk/src/waeup/sirp/university/department.py
r7195 r7333 46 46 self.title_prefix = title_prefix 47 47 self.code = code 48 self.courses = createObject(u'waeup.Course Container')48 self.courses = createObject(u'waeup.CoursesContainer') 49 49 self.courses.__parent__ = self 50 50 self.courses.__name__ = 'courses' 51 self.certificates = createObject(u'waeup.Certificate Container')51 self.certificates = createObject(u'waeup.CertificatesContainer') 52 52 self.certificates.__parent__ = self 53 53 self.certificates.__name__ = 'certificates' -
main/waeup.sirp/trunk/src/waeup/sirp/university/department.txt
r7321 r7333 81 81 .. attribute:: courses 82 82 83 (ICourse Container instance) A container for courses.83 (ICoursesContainer instance) A container for courses. 84 84 85 85 Each department has a courses container: 86 86 87 87 >>> mydept.courses 88 <waeup.sirp.university.course container.CourseContainer object at 0x...>88 <waeup.sirp.university.coursescontainer.CoursesContainer object at 0x...> 89 89 90 90 91 91 .. attribute:: certificates 92 92 93 (ICertificate Container instance) A container for certificates.93 (ICertificatesContainer instance) A container for certificates. 94 94 95 95 Each department has a certificate container, that holds the … … 97 97 98 98 >>> mydept.certificates 99 <waeup.sirp...certificate container.CertificateContainer object at 0x...>99 <waeup.sirp...certificatescontainer.CertificatesContainer object at 0x...> 100 100 101 101 Utilities -
main/waeup.sirp/trunk/src/waeup/sirp/university/facultiescontainer.py
r7331 r7333 20 20 from zope.interface import implementedBy 21 21 from waeup.sirp.interfaces import ISIRPPluggable 22 from waeup.sirp.university.interfaces import IFacult yContainer, IFaculty22 from waeup.sirp.university.interfaces import IFacultiesContainer, IFaculty 23 23 24 class Facult yContainer(grok.Container):24 class FacultiesContainer(grok.Container): 25 25 """See interfaces for description. 26 26 """ 27 grok.implements(IFacult yContainer)27 grok.implements(IFacultiesContainer) 28 28 grok.require('waeup.manageUniversity') 29 29 30 30 def addFaculty(self, faculty): 31 31 if not IFaculty.providedBy(faculty): 32 raise TypeError('Facult yContainers contain only IFaculty instances')32 raise TypeError('FacultiesContainers contain only IFaculty instances') 33 33 self[faculty.code] = faculty 34 34 return 35 35 36 class Facult yContainerFactory(grok.GlobalUtility):36 class FacultiesContainerFactory(grok.GlobalUtility): 37 37 """A factory for faculty containers. 38 38 """ 39 39 grok.implements(IFactory) 40 grok.name(u'waeup.Facult yContainer')41 title = u"Create a new facult ycontainer.",42 description = u"This factory instantiates new faculty containers."40 grok.name(u'waeup.FacultiesContainer') 41 title = u"Create a new facultiescontainer.", 42 description = u"This factory instantiates new containers for faculties." 43 43 44 44 def __call__(self, *args, **kw): 45 return Facult yContainer(*args, **kw)45 return FacultiesContainer(*args, **kw) 46 46 47 47 def getInterfaces(self): 48 return implementedBy(Facult yContainer)48 return implementedBy(FacultiesContainer) 49 49 50 50 class AcademicsPlugin(grok.GlobalUtility): 51 """A plugin that creates a faculty containerinside a university.51 """A plugin that creates container for faculties inside a university. 52 52 """ 53 53 grok.implements(ISIRPPluggable) … … 56 56 def setup(self, site, name, logger): 57 57 if 'faculties' in site.keys(): 58 logger.warn('Could not create faculty containerin SIRP.')58 logger.warn('Could not create container for faculties in SIRP.') 59 59 return 60 site['faculties'] = Facult yContainer()61 logger.info('C reated faculty container for University')60 site['faculties'] = FacultiesContainer() 61 logger.info('Container for faculties created') 62 62 return 63 63 -
main/waeup.sirp/trunk/src/waeup/sirp/university/facultiescontainer.txt
r7331 r7333 1 :mod:`waeup.sirp.university.facult ycontainer` -- Faculty Containers2 ******************************************************************* 1 :mod:`waeup.sirp.university.facultiescontainer` -- Faculty Containers 2 ********************************************************************* 3 3 4 .. module:: waeup.sirp.university.facult ycontainer4 .. module:: waeup.sirp.university.facultiescontainer 5 5 6 6 Components that represent faculty containers. … … 13 13 ======================================= 14 14 15 :class:`Facult yContainer`16 ------------------------- 15 :class:`FacultiesContainer` 16 --------------------------- 17 17 18 .. class:: Facult yContainer()18 .. class:: FacultiesContainer() 19 19 20 20 Create a faculty container: 21 21 22 >>> from waeup.sirp.university.facult ycontainer import FacultyContainer23 >>> mycontainer = Facult yContainer()22 >>> from waeup.sirp.university.facultiescontainer import FacultiesContainer 23 >>> mycontainer = FacultiesContainer() 24 24 >>> mycontainer 25 <waeup.sirp.university.facult ycontainer.FacultyContainer object at 0x...>25 <waeup.sirp.university.facultiescontainer.FacultiesContainer object at 0x...> 26 26 27 Another way to create :class:`Facult yContainer` instances is by asking28 for a factory called ``waeup.Facult yContainer``. This way we can create a27 Another way to create :class:`FacultiesContainer` instances is by asking 28 for a factory called ``waeup.FacultiesContainer``. This way we can create a 29 29 faculty without importing a class: 30 30 31 31 >>> from zope.component import createObject 32 >>> mycontainer = createObject(u'waeup.Facult yContainer')32 >>> mycontainer = createObject(u'waeup.FacultiesContainer') 33 33 >>> mycontainer 34 <waeup.sirp.university.facult ycontainer.FacultyContainer object at 0x...>34 <waeup.sirp.university.facultiescontainer.FacultiesContainer object at 0x...> 35 35 36 :class:`Facult yContainer` instances have the attributes required by the37 `IFacult yContainer` interface:36 :class:`FacultiesContainer` instances have the attributes required by the 37 `IFacultiesContainer` interface: 38 38 39 >>> from waeup.sirp.university.interfaces import IFacult yContainer40 >>> IFacult yContainer.providedBy(mycontainer)39 >>> from waeup.sirp.university.interfaces import IFacultiesContainer 40 >>> IFacultiesContainer.providedBy(mycontainer) 41 41 True 42 42 43 43 >>> from zope.interface.verify import verifyObject 44 >>> verifyObject(IFacult yContainer, mycontainer)44 >>> verifyObject(IFacultiesContainer, mycontainer) 45 45 True 46 46 … … 53 53 Traceback (most recent call last): 54 54 ... 55 TypeError: Facult yContainers contain only IFaculty instances55 TypeError: FacultiesContainers contain only IFaculty instances 56 56 57 57 >>> list(mycontainer.values()) … … 81 81 This plugin component tells under which name (``faculties``) an 82 82 instance of academics stuff should be created in plain SIRP 83 instances. It also tells the factory name for Facult yContainer83 instances. It also tells the factory name for FacultiesContainer 84 84 instances, which serve as root object for academics stuff in SIRP apps. 85 85 86 86 87 :class:`Facult yContainerFactory`88 -------------------------------- 87 :class:`FacultiesContainerFactory` 88 ---------------------------------- 89 89 90 .. class:: Facult yContainerFactory()90 .. class:: FacultiesContainerFactory() 91 91 92 .. attribute:: grok.name(u'waeup.Facult yContainer')92 .. attribute:: grok.name(u'waeup.FacultiesContainer') 93 93 94 94 .. attribute:: grok.implements(IFactoryContainer) 95 95 96 A named utility to deliver new instances of :class:`Facult yContainer`96 A named utility to deliver new instances of :class:`FacultiesContainer` 97 97 without the need to import the implementation before: 98 98 99 99 >>> from zope.component import createObject 100 >>> mycontainer = createObject(u'waeup.Facult yContainer')100 >>> mycontainer = createObject(u'waeup.FacultiesContainer') 101 101 >>> mycontainer 102 <waeup.sirp.university.facult ycontainer.FacultyContainer object at 0x...>102 <waeup.sirp.university.facultiescontainer.FacultiesContainer object at 0x...> 103 103 104 104 The factory complies with the specifications from the … … 107 107 >>> from zope.interface.verify import verifyClass 108 108 >>> from zope.component.interfaces import IFactory 109 >>> from waeup.sirp.university.facult ycontainer import (110 ... Facult yContainerFactory)111 >>> verifyClass(IFactory, Facult yContainerFactory)109 >>> from waeup.sirp.university.facultiescontainer import ( 110 ... FacultiesContainerFactory) 111 >>> verifyClass(IFactory, FacultiesContainerFactory) 112 112 True 113 113 … … 115 115 object from the factory: 116 116 117 >>> fac_container_factory = Facult yContainerFactory()117 >>> fac_container_factory = FacultiesContainerFactory() 118 118 >>> fac_container_factory.getInterfaces() 119 <implementedBy waeup.sirp.university.facult ycontainer.FacultyContainer>119 <implementedBy waeup.sirp.university.facultiescontainer.FacultiesContainer> 120 120 121 121 Examples 122 122 ======== 123 123 124 We can easily create `Facult yContainers`:124 We can easily create `FacultiesContainers`: 125 125 126 >>> from waeup.sirp.university.facult ycontainer import FacultyContainer127 >>> mycontainer = Facult yContainer()126 >>> from waeup.sirp.university.facultiescontainer import FacultiesContainer 127 >>> mycontainer = FacultiesContainer() 128 128 129 Faculty containers provide `IFacult yContainer`:129 Faculty containers provide `IFacultiesContainer`: 130 130 131 >>> from waeup.sirp.university.interfaces import IFacult yContainer132 >>> IFacult yContainer.providedBy(mycontainer)131 >>> from waeup.sirp.university.interfaces import IFacultiesContainer 132 >>> IFacultiesContainer.providedBy(mycontainer) 133 133 True 134 134 135 135 Another way to get a faculty container -- without importing the class 136 136 -- is via factories. We registered a factory for faculty containers 137 under the name ``waeup.facult ycontainer``:137 under the name ``waeup.facultiescontainer``: 138 138 139 139 >>> from zope.component import createObject 140 >>> createObject(u'waeup.Facult yContainer')141 <waeup.sirp.university.facult ycontainer.FacultyContainer object at 0x...>140 >>> createObject(u'waeup.FacultiesContainer') 141 <waeup.sirp.university.facultiescontainer.FacultiesContainer object at 0x...> 142 142 143 This way we get a thing that implements IFacult yContainer without143 This way we get a thing that implements IFacultiesContainer without 144 144 imports or similar. 145 145 146 146 We can be sure, that the full interface is supported by the 147 Facult yContainer class::147 FacultiesContainer class:: 148 148 149 149 >>> from zope.interface.verify import verifyClass 150 >>> verifyClass(IFacult yContainer, FacultyContainer)150 >>> verifyClass(IFacultiesContainer, FacultiesContainer) 151 151 True 152 152 … … 161 161 Traceback (most recent call last): 162 162 ... 163 TypeError: Facult yContainers contain only IFaculty instances163 TypeError: FacultiesContainers contain only IFaculty instances 164 164 165 165 Okay, so we have to get a faculty first:: -
main/waeup.sirp/trunk/src/waeup/sirp/university/interfaces.py
r7321 r7333 73 73 IFacultyAdd['code'].order = IFaculty['code'].order 74 74 75 class IFacult yContainer(ISIRPContainer):75 class IFacultiesContainer(ISIRPContainer): 76 76 """A container for faculties. 77 77 """ … … 124 124 IDepartmentAdd['code'].order = IDepartment['code'].order 125 125 126 class ICourse Container(ISIRPContainer):126 class ICoursesContainer(ISIRPContainer): 127 127 """A container for faculties. 128 128 """ … … 248 248 ICertificateAdd['code'].order = ICertificate['code'].order 249 249 250 class ICertificate Container(ISIRPContainer):250 class ICertificatesContainer(ISIRPContainer): 251 251 """A container for certificates. 252 252 """ -
main/waeup.sirp/trunk/src/waeup/sirp/university/tests/test_certificatescontainer.py
r7331 r7333 30 30 FunctionalLayer, doctestsuite_for_module, FunctionalTestCase) 31 31 from waeup.sirp.university.certificate import Certificate 32 from waeup.sirp.university.certificate container import CertificateContainer33 from waeup.sirp.university.interfaces import ICertificate Container32 from waeup.sirp.university.certificatescontainer import CertificatesContainer 33 from waeup.sirp.university.interfaces import ICertificatesContainer 34 34 35 35 36 class Certificate ContainerTests(FunctionalTestCase):36 class CertificatesContainerTests(FunctionalTestCase): 37 37 38 38 layer = FunctionalLayer 39 39 40 40 def setUp(self): 41 super(Certificate ContainerTests, self).setUp()41 super(CertificatesContainerTests, self).setUp() 42 42 43 43 # Setup a sample site for each test … … 52 52 53 53 def tearDown(self): 54 super(Certificate ContainerTests, self).tearDown()54 super(CertificatesContainerTests, self).tearDown() 55 55 clearSite() 56 56 shutil.rmtree(self.dc_root) … … 58 58 def test_create(self): 59 59 # we can create instances 60 container = Certificate Container()61 result = isinstance(container, Certificate Container)60 container = CertificatesContainer() 61 result = isinstance(container, CertificatesContainer) 62 62 assert result is True 63 63 64 def test_provides_icertificate container(self):64 def test_provides_icertificatescontainer(self): 65 65 # instances tell they provide their main interface 66 container = Certificate Container()67 result = ICertificate Container.providedBy(container)66 container = CertificatesContainer() 67 result = ICertificatesContainer.providedBy(container) 68 68 assert result is True 69 69 70 70 def test_interfaces(self): 71 71 # class and instances comply with their main interface 72 container = Certificate Container()73 self.assertTrue(verifyClass(ICertificate Container, CertificateContainer))74 self.assertTrue(verifyObject(ICertificate Container, container))72 container = CertificatesContainer() 73 self.assertTrue(verifyClass(ICertificatesContainer, CertificatesContainer)) 74 self.assertTrue(verifyObject(ICertificatesContainer, container)) 75 75 76 76 def test_add_certificate_non_icertificate(self): 77 77 # we cannot add certificates that do not implement ICertificate. 78 container = Certificate Container()78 container = CertificatesContainer() 79 79 self.assertRaises( 80 80 TypeError, container.addCertificate, 'some_string') … … 82 82 def test_add_certificate_no_duplicate_entry(self): 83 83 # we cannot add certificates that are registered already. 84 container = Certificate Container()84 container = CertificatesContainer() 85 85 # We must place this container in the ZODB to make catalogs work. 86 86 self.app['certs'] = container … … 94 94 def test_setitem_duplicate_entry(self): 95 95 # we cannot add certificates whose code exists already in catalog 96 container1 = Certificate Container()97 container2 = Certificate Container()96 container1 = CertificatesContainer() 97 container2 = CertificatesContainer() 98 98 self.app['certs1'] = container1 # enable catalogs 99 99 self.app['certs2'] = container2 … … 108 108 def test_setitem_name_unequal_code(self): 109 109 # we cannot add certificates whose code != key 110 container = Certificate Container()110 container = CertificatesContainer() 111 111 self.app['certs'] = container # enable catalogs 112 112 cert1 = Certificate(code="CERT1") … … 118 118 def test_clear(self): 119 119 # clear() really empties the container. 120 container = Certificate Container()120 container = CertificatesContainer() 121 121 self.app['certs'] = container # enable catalogs 122 122 cert1 = Certificate(code="CERT1") … … 130 130 def test_suite(): 131 131 suite = unittest.TestSuite(( 132 unittest.makeSuite(Certificate ContainerTests),132 unittest.makeSuite(CertificatesContainerTests), 133 133 doctestsuite_for_module( 134 'waeup.sirp.university.certificate container'),134 'waeup.sirp.university.certificatescontainer'), 135 135 )) 136 136 return suite -
main/waeup.sirp/trunk/src/waeup/sirp/university/tests/test_coursescontainer.py
r7331 r7333 21 21 import unittest 22 22 from zope.interface.verify import verifyClass, verifyObject 23 from waeup.sirp.university.interfaces import ICourse Container24 from waeup.sirp.university import Course Container, Course23 from waeup.sirp.university.interfaces import ICoursesContainer 24 from waeup.sirp.university import CoursesContainer, Course 25 25 26 class Course ContainerTests(unittest.TestCase):26 class CoursesContainerTests(unittest.TestCase): 27 27 28 28 def test_ifaces(self): 29 container = Course Container()30 self.assertTrue(verifyClass(ICourse Container, CourseContainer))31 self.assertTrue(verifyObject(ICourse Container, container))29 container = CoursesContainer() 30 self.assertTrue(verifyClass(ICoursesContainer, CoursesContainer)) 31 self.assertTrue(verifyObject(ICoursesContainer, container)) 32 32 33 33 def test_setitem_name_ne_code(self): 34 34 # If we add a course under a wrong name that will give an error 35 container = Course Container()35 container = CoursesContainer() 36 36 course = Course(code='MYCOURSE') 37 37 self.assertRaises( -
main/waeup.sirp/trunk/src/waeup/sirp/university/tests/test_facultiescontainer.py
r7331 r7333 17 17 ## 18 18 19 # Tests for Facult yContainer.19 # Tests for FacultiesContainer. 20 20 import logging 21 21 import unittest … … 23 23 from zope.interface.verify import verifyObject, verifyClass 24 24 from waeup.sirp.testing import FunctionalTestCase, FunctionalLayer 25 from waeup.sirp.university.interfaces import IFacult yContainer26 from waeup.sirp.university import Facult yContainer27 from waeup.sirp.university.facult ycontainer import AcademicsPlugin25 from waeup.sirp.university.interfaces import IFacultiesContainer 26 from waeup.sirp.university import FacultiesContainer 27 from waeup.sirp.university.facultiescontainer import AcademicsPlugin 28 28 29 29 class FakeLogger(object): … … 54 54 return result 55 55 56 class Facult yContainerTests(unittest.TestCase):56 class FacultiesContainerTests(unittest.TestCase): 57 57 58 58 def test_ifaces(self): 59 container = Facult yContainer()60 self.assertTrue(verifyClass(IFacult yContainer, FacultyContainer))61 self.assertTrue(verifyObject(IFacult yContainer, container))59 container = FacultiesContainer() 60 self.assertTrue(verifyClass(IFacultiesContainer, FacultiesContainer)) 61 self.assertTrue(verifyObject(IFacultiesContainer, container)) 62 62 63 63 class AcademicsPluginTests(unittest.TestCase): … … 76 76 plugin.setup(site, 'testsite', logger) 77 77 self.assertTrue('faculties' in site.keys()) 78 self.assertTrue(isinstance(site['faculties'], Facult yContainer))78 self.assertTrue(isinstance(site['faculties'], FacultiesContainer)) 79 79 self.assertEqual( 80 80 self._logger_factory.get_messages(), 81 'C reated faculty container for University\n'81 'Container for faculties created\n' 82 82 ) 83 83 … … 90 90 self.assertEqual( 91 91 self._logger_factory.get_messages(), 92 'Could not create faculty containerin SIRP.\n'92 'Could not create container for faculties in SIRP.\n' 93 93 ) 94 94 … … 99 99 plugin.update(site, 'testsite', logger) 100 100 self.assertTrue('faculties' in site.keys()) 101 self.assertTrue(isinstance(site['faculties'], Facult yContainer))101 self.assertTrue(isinstance(site['faculties'], FacultiesContainer)) 102 102 self.assertEqual( 103 103 self._logger_factory.get_messages(), 104 'C reated faculty container for University\n'104 'Container for faculties created\n' 105 105 ) 106 106 -
main/waeup.sirp/trunk/src/waeup/sirp/university/tests/test_university.py
r7195 r7333 27 27 names = globals().keys() 28 28 self.assertTrue('Course' in names) 29 self.assertTrue('Course Container' in names)29 self.assertTrue('CoursesContainer' in names) 30 30 self.assertTrue('Faculty' in names) 31 self.assertTrue('Facult yContainer' in names)31 self.assertTrue('FacultiesContainer' in names) 32 32 33 33 def test_suite():
Note: See TracChangeset for help on using the changeset viewer.