source: main/waeup.sirp/branches/ulif-fasttables/src/waeup/sirp/university/department.py @ 5314

Last change on this file since 5314 was 5005, checked in by uli, 15 years ago

Fix references to academics stuff interfaces. This is the first step to make academics stuff pluggable.

  • Property svn:eol-style set to native
File size: 1.8 KB
Line 
1"""University departments.
2"""
3import grok
4from zope.component import createObject
5from zope.component.interfaces import IFactory
6from zope.interface import implementedBy
7from waeup.sirp.university.interfaces import IDepartment
8
9class Department(grok.Container):
10    """A university department.
11    """
12    grok.implements(IDepartment)
13
14    # A simple counter for ids.
15    next_id = 0L
16   
17    def __init__(self,
18                 title=u'Unnamed Department',
19                 title_prefix=u'department',
20                 code=u"NA", **kw):
21        super(Department, self).__init__(**kw)
22        self.title = title
23        self.title_prefix = title_prefix
24        self.code = code
25        self.courses = createObject(u'waeup.CourseContainer')
26        self.courses.__parent__ = self
27        self.courses.__name__ = 'courses'
28        self.certificates = createObject(u'waeup.CertificateContainer')
29        self.certificates.__parent__ = self
30        self.certificates.__name__ = 'certificates'
31
32    def traverse(self, name):
33        """Deliver appropriate containers, if someone wants to go to courses
34        or departments.
35        """
36        if name == 'courses':
37            return self.courses
38        elif name == 'certificates':
39            return self.certificates
40        return None
41       
42
43class DepartmentFactory(grok.GlobalUtility):
44    """A factory for department containers.
45    """
46    grok.implements(IFactory)
47    grok.name(u'waeup.Department')
48    title = u"Create a new department.",
49    description = u"This factory instantiates new department instances."
50
51    def __call__(self, *args, **kw):
52        return Department(*args, **kw)
53
54    def getInterfaces(self):
55        """Get interfaces of objects provided by this factory.
56        """
57        return implementedBy(Department)
Note: See TracBrowser for help on using the repository browser.