Changeset 6633
- Timestamp:
- 26 Aug 2011, 10:10:18 (13 years ago)
- Location:
- main/waeup.sirp/trunk/src/waeup/sirp
- Files:
-
- 1 added
- 7 edited
Legend:
- Unmodified
- Added
- Removed
-
main/waeup.sirp/trunk/src/waeup/sirp/app.py
r6621 r6633 2 2 from hurry.file.interfaces import IFileRetrieval 3 3 from zope.authentication.interfaces import IAuthentication 4 from zope.component import createObject,getUtilitiesFor4 from zope.component import getUtilitiesFor 5 5 from zope.component.interfaces import ObjectEvent 6 6 from zope.pluggableauth import PluggableAuthentication 7 7 from waeup.sirp.authentication import setup_authentication 8 8 from waeup.sirp.datacenter import DataCenter 9 from waeup.sirp.students.container import StudentsContainer 9 10 from waeup.sirp.imagestorage import ImageStorageFileRetrieval, ImageStorage 10 11 from waeup.sirp.interfaces import ( … … 42 43 self['datacenter'] = DataCenter() 43 44 self['images'] = ImageStorage() 44 self['students'] = createObject(u'waeup.StudentsContainer')45 self['students'] = StudentsContainer() 45 46 self._createPlugins() 46 47 -
main/waeup.sirp/trunk/src/waeup/sirp/students/browser.py
r6632 r6633 211 211 student_id = self.request.form.get('form.student_id') 212 212 student = createObject(u'waeup.Student') 213 student.student_id = student_id 213 214 self.applyData(student, **data) 214 215 #import pdb; pdb.set_trace() 215 216 try: 216 self.context [student_id] = student217 self.context.addStudent(student) 217 218 except KeyError: 218 219 self.flash('The student id chosen already exists.') -
main/waeup.sirp/trunk/src/waeup/sirp/students/container.py
r6621 r6633 21 21 from zope.component.interfaces import IFactory 22 22 from zope.interface import implementedBy 23 from waeup.sirp.students.interfaces import IStudentsContainer 23 from waeup.sirp.students.interfaces import ( 24 IStudentsContainer, IStudent) 25 from waeup.sirp.students.studycourse import StudentStudyCourse 24 26 25 27 class StudentsContainer(grok.Container): … … 35 37 def clear(self, id=None, archive=True): 36 38 raise NotImplementedError() 37 38 class StudentsContainerFactory(grok.GlobalUtility):39 """A factory for students containers.40 """41 grok.implements(IFactory)42 grok.name(u'waeup.StudentsContainer')43 title = u"Create a new students container.",44 description = u"This factory instantiates new students containers."45 39 46 def __call__(self, *args, **kw): 47 return StudentsContainer() 48 49 def getInterfaces(self): 50 return implementedBy(StudentsContainer) 40 def addStudent(self, student): 41 """Add a student with subcontainers. 42 """ 43 if not IStudent.providedBy(student): 44 raise TypeError('StudentsContainers contain only IStudent instances') 45 self[student.student_id] = student 46 studycourse = StudentStudyCourse() 47 self[student.student_id]['studycourse'] = studycourse 48 return -
main/waeup.sirp/trunk/src/waeup/sirp/students/interfaces.py
r6631 r6633 47 47 """ 48 48 49 def addStudent(faculty): 50 """Add an IStudent object and subcontainers. 51 52 """ 53 49 54 def archive(id=None): 50 55 """Create on-dist archive of students. … … 76 81 database. 77 82 """ 83 84 class IStudentStudyCourse(IWAeUPObject): 85 """A container for student study levels. 86 87 """ 88 89 certificate_code = schema.TextLine( 90 title = u'Certificate Code', 91 default = u'None', 92 required = True, 93 ) -
main/waeup.sirp/trunk/src/waeup/sirp/students/tests/test_container.py
r6621 r6633 25 25 ) 26 26 from waeup.sirp.students.container import ( 27 StudentsContainer, StudentsContainerFactory,27 StudentsContainer, 28 28 ) 29 29 from waeup.sirp.testing import FunctionalLayer … … 50 50 self.assertRaises( 51 51 NotImplementedError, container.clear) 52 53 class StudentsContainerFactoryTest(FunctionalTestCase):54 55 layer = FunctionalLayer56 57 def setUp(self):58 self.factory = StudentsContainerFactory()59 60 def tearDown(self):61 pass62 63 def test_interfaces(self):64 verifyClass(IFactory, StudentsContainerFactory)65 verifyObject(IFactory, self.factory)66 67 def test_factory(self):68 obj = self.factory()69 assert isinstance(obj, StudentsContainer)70 71 def test_getInterfaces(self):72 implemented_by = self.factory.getInterfaces()73 assert implemented_by.isOrExtends(IStudentsContainer) -
main/waeup.sirp/trunk/src/waeup/sirp/students/tests/test_student.py
r6632 r6633 30 30 Student, StudentFactory, 31 31 ) 32 from waeup.sirp.students.studycourse import ( 33 StudentStudyCourse, 34 ) 32 35 from waeup.sirp.students.interfaces import ( 33 IStudent, 36 IStudent, IStudentStudyCourse, 34 37 ) 35 38 from waeup.sirp.testing import FunctionalLayer … … 42 45 super(StudentTest, self).setUp() 43 46 self.student = Student() 47 self.studycourse = StudentStudyCourse() 44 48 return 45 49 … … 51 55 verify.verifyClass(IStudent, Student) 52 56 verify.verifyObject(IStudent, self.student) 57 verify.verifyClass(IStudentStudyCourse, StudentStudyCourse) 58 verify.verifyObject(IStudentStudyCourse, self.studycourse) 53 59 return 54 60 -
main/waeup.sirp/trunk/src/waeup/sirp/university/interfaces.py
r6561 r6633 62 62 """Add an IFactulty object. 63 63 64 Returns the key, under which the object was stored.65 64 """ 66 65 class IDepartment(IWAeUPObject):
Note: See TracChangeset for help on using the changeset viewer.